Revert "Revert changes to 8fa36e00ec722191692f602de3529c424db87d1a"
This reverts commit 5084478bc9
.
This commit is contained in:
parent
5084478bc9
commit
6d3ff5a6f5
48
backend/Cargo.lock
generated
48
backend/Cargo.lock
generated
@ -158,7 +158,6 @@ dependencies = [
|
|||||||
"isahc",
|
"isahc",
|
||||||
"lazy_static",
|
"lazy_static",
|
||||||
"log",
|
"log",
|
||||||
"once_cell",
|
|
||||||
"regex",
|
"regex",
|
||||||
"reqwest",
|
"reqwest",
|
||||||
"rocket",
|
"rocket",
|
||||||
@ -347,9 +346,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cookie"
|
name = "cookie"
|
||||||
version = "0.17.0"
|
version = "0.18.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "7efb37c3e1ccb1ff97164ad95ac1606e8ccd35b3fa0a7d99a304c7f4a428cc24"
|
checksum = "3cd91cf61412820176e137621345ee43b3f4423e589e7ae4e50d601d93e35ef8"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"percent-encoding",
|
"percent-encoding",
|
||||||
"time 0.3.27",
|
"time 0.3.27",
|
||||||
@ -1319,7 +1318,6 @@ checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"autocfg",
|
"autocfg",
|
||||||
"hashbrown 0.12.3",
|
"hashbrown 0.12.3",
|
||||||
"serde",
|
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@ -1330,6 +1328,7 @@ checksum = "d5477fe2230a79769d8dc68e0eabf5437907c0457a5614a9e8dddb67f65eb65d"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"equivalent",
|
"equivalent",
|
||||||
"hashbrown 0.14.0",
|
"hashbrown 0.14.0",
|
||||||
|
"serde",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@ -1933,7 +1932,7 @@ checksum = "61a386cd715229d399604b50d1361683fe687066f42d56f54be995bc6868f71c"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"inlinable_string",
|
"inlinable_string",
|
||||||
"pear_codegen",
|
"pear_codegen",
|
||||||
"yansi 1.0.0-rc.1",
|
"yansi",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@ -2162,7 +2161,7 @@ dependencies = [
|
|||||||
"quote",
|
"quote",
|
||||||
"syn 2.0.29",
|
"syn 2.0.29",
|
||||||
"version_check",
|
"version_check",
|
||||||
"yansi 1.0.0-rc.1",
|
"yansi",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@ -2456,9 +2455,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rocket"
|
name = "rocket"
|
||||||
version = "0.5.0-rc.3"
|
version = "0.5.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "58734f7401ae5cfd129685b48f61182331745b357b96f2367f01aebaf1cc9cc9"
|
checksum = "9e7bb57ccb26670d73b6a47396c83139447b9e7878cab627fdfe9ea8da489150"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"async-stream",
|
"async-stream",
|
||||||
"async-trait",
|
"async-trait",
|
||||||
@ -2468,8 +2467,7 @@ dependencies = [
|
|||||||
"either",
|
"either",
|
||||||
"figment",
|
"figment",
|
||||||
"futures",
|
"futures",
|
||||||
"indexmap 1.9.3",
|
"indexmap 2.0.0",
|
||||||
"is-terminal",
|
|
||||||
"log",
|
"log",
|
||||||
"memchr",
|
"memchr",
|
||||||
"multer",
|
"multer",
|
||||||
@ -2492,37 +2490,38 @@ dependencies = [
|
|||||||
"ubyte",
|
"ubyte",
|
||||||
"uuid",
|
"uuid",
|
||||||
"version_check",
|
"version_check",
|
||||||
"yansi 0.5.1",
|
"yansi",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rocket_codegen"
|
name = "rocket_codegen"
|
||||||
version = "0.5.0-rc.3"
|
version = "0.5.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "7093353f14228c744982e409259fb54878ba9563d08214f2d880d59ff2fc508b"
|
checksum = "a2238066abf75f21be6cd7dc1a09d5414a671f4246e384e49fe3f8a4936bd04c"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"devise",
|
"devise",
|
||||||
"glob",
|
"glob",
|
||||||
"indexmap 1.9.3",
|
"indexmap 2.0.0",
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"rocket_http",
|
"rocket_http",
|
||||||
"syn 2.0.29",
|
"syn 2.0.29",
|
||||||
"unicode-xid",
|
"unicode-xid",
|
||||||
|
"version_check",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rocket_http"
|
name = "rocket_http"
|
||||||
version = "0.5.0-rc.3"
|
version = "0.5.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "936012c99162a03a67f37f9836d5f938f662e26f2717809761a9ac46432090f4"
|
checksum = "37a1663694d059fe5f943ea5481363e48050acedd241d46deb2e27f71110389e"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cookie 0.17.0",
|
"cookie 0.18.0",
|
||||||
"either",
|
"either",
|
||||||
"futures",
|
"futures",
|
||||||
"http",
|
"http",
|
||||||
"hyper",
|
"hyper",
|
||||||
"indexmap 1.9.3",
|
"indexmap 2.0.0",
|
||||||
"log",
|
"log",
|
||||||
"memchr",
|
"memchr",
|
||||||
"pear",
|
"pear",
|
||||||
@ -3183,9 +3182,9 @@ checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "state"
|
name = "state"
|
||||||
version = "0.5.3"
|
version = "0.6.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "dbe866e1e51e8260c9eed836a042a5e7f6726bb2b411dffeaa712e19c388f23b"
|
checksum = "2b8c4a4445d81357df8b1a650d0d0d6fbbbfe99d064aa5e02f3e4022061476d8"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"loom",
|
"loom",
|
||||||
]
|
]
|
||||||
@ -3962,17 +3961,14 @@ dependencies = [
|
|||||||
"windows-sys",
|
"windows-sys",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "yansi"
|
|
||||||
version = "0.5.1"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "09041cd90cf85f7f8b2df60c646f853b7f535ce68f85244eb6731cf89fa498ec"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "yansi"
|
name = "yansi"
|
||||||
version = "1.0.0-rc.1"
|
version = "1.0.0-rc.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "1367295b8f788d371ce2dbc842c7b709c73ee1364d30351dd300ec2203b12377"
|
checksum = "1367295b8f788d371ce2dbc842c7b709c73ee1364d30351dd300ec2203b12377"
|
||||||
|
dependencies = [
|
||||||
|
"is-terminal",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "zeroize"
|
name = "zeroize"
|
||||||
|
@ -7,7 +7,7 @@ edition = "2021"
|
|||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
reqwest = { version = "0.11", features = ["json", "cookies"] }
|
reqwest = { version = "0.11", features = ["json", "cookies"] }
|
||||||
rocket = { version = "=0.5.0-rc.3" , features = ["json", "msgpack", "uuid"] }
|
rocket = { version = "0.5.0" , features = ["json", "msgpack", "uuid"] }
|
||||||
sqlx = { version = "0.7.1", features = [ "runtime-tokio", "tls-rustls", "mysql", "macros", "chrono" ] }
|
sqlx = { version = "0.7.1", features = [ "runtime-tokio", "tls-rustls", "mysql", "macros", "chrono" ] }
|
||||||
dotenvy = "0.15.7"
|
dotenvy = "0.15.7"
|
||||||
serde = "1.0.188"
|
serde = "1.0.188"
|
||||||
@ -16,7 +16,6 @@ scraper = "0.17.1"
|
|||||||
isahc = { version = "1.7.2", features = ["cookies"] }
|
isahc = { version = "1.7.2", features = ["cookies"] }
|
||||||
urlencoding = "2.1.3"
|
urlencoding = "2.1.3"
|
||||||
lazy_static = "1.4.0"
|
lazy_static = "1.4.0"
|
||||||
once_cell = "1.18.0"
|
|
||||||
log = "0.4.20"
|
log = "0.4.20"
|
||||||
env_logger = "0.10.0"
|
env_logger = "0.10.0"
|
||||||
bardecoder = "0.5.0"
|
bardecoder = "0.5.0"
|
||||||
|
@ -1,9 +1,6 @@
|
|||||||
use cors::Cors;
|
use cors::Cors;
|
||||||
use once_cell::sync::OnceCell;
|
|
||||||
use sqlx::Connection;
|
use sqlx::Connection;
|
||||||
use sqlx::MySql;
|
|
||||||
use sqlx::MySqlConnection;
|
use sqlx::MySqlConnection;
|
||||||
use sqlx::Pool;
|
|
||||||
use std::env;
|
use std::env;
|
||||||
use std::time::Instant;
|
use std::time::Instant;
|
||||||
|
|
||||||
@ -17,8 +14,6 @@ mod online_classroom;
|
|||||||
|
|
||||||
pub mod json_result;
|
pub mod json_result;
|
||||||
|
|
||||||
static DB: OnceCell<Pool<MySql>> = OnceCell::new();
|
|
||||||
|
|
||||||
/// Opens & returns a connection to the database
|
/// Opens & returns a connection to the database
|
||||||
///
|
///
|
||||||
/// We don't use a connection pool because on some days, on the afternoon,
|
/// We don't use a connection pool because on some days, on the afternoon,
|
||||||
|
@ -35,7 +35,9 @@ impl Course {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
let results = sqlx::query!("SELECT * FROM course").fetch_all(&mut db).await;
|
let results = sqlx::query!("SELECT * FROM course")
|
||||||
|
.fetch_all(&mut db)
|
||||||
|
.await;
|
||||||
|
|
||||||
let results = match results {
|
let results = match results {
|
||||||
Ok(res) => res,
|
Ok(res) => res,
|
||||||
|
@ -103,6 +103,9 @@ pub async fn request(url: String) -> Result<String, String> {
|
|||||||
// Get the stored client
|
// Get the stored client
|
||||||
let jar = SESSION_COOKIE.read().unwrap().jar.clone();
|
let jar = SESSION_COOKIE.read().unwrap().jar.clone();
|
||||||
|
|
||||||
|
log::info!("Classroom request: url: {}", url);
|
||||||
|
log::info!("Classroom request: cookie jar: {:?}", jar);
|
||||||
|
|
||||||
let uri = format!("{}{}", classroom_url, url);
|
let uri = format!("{}{}", classroom_url, url);
|
||||||
|
|
||||||
// Do the request
|
// Do the request
|
||||||
@ -252,11 +255,23 @@ async fn login() -> Result<(), String> {
|
|||||||
match response {
|
match response {
|
||||||
Ok(mut r) => {
|
Ok(mut r) => {
|
||||||
if r.status() == isahc::http::StatusCode::FOUND {
|
if r.status() == isahc::http::StatusCode::FOUND {
|
||||||
// TODO: Even if this is a 302, it might not be a successful login
|
let html = match r.text() {
|
||||||
|
Ok(t) => t,
|
||||||
|
Err(err) => {
|
||||||
|
return Err(format!("Error getting text from login response: {:?}", err))
|
||||||
|
}
|
||||||
|
};
|
||||||
|
log::info!("classroom login: 302 response.");
|
||||||
|
log_html(&html);
|
||||||
|
|
||||||
|
log::info!("classroom login cookies: {:?}", jar);
|
||||||
|
|
||||||
// check Set-Cookie header
|
// check Set-Cookie header
|
||||||
SESSION_COOKIE.write().unwrap().jar = jar.clone();
|
SESSION_COOKIE.write().unwrap().jar = jar.clone();
|
||||||
Ok(())
|
Ok(())
|
||||||
} else {
|
} else {
|
||||||
|
log::info!("classroom login: not 302");
|
||||||
|
|
||||||
// Write html to file
|
// Write html to file
|
||||||
match r.text() {
|
match r.text() {
|
||||||
Ok(t) => {
|
Ok(t) => {
|
||||||
|
3
frontend/.gitignore
vendored
3
frontend/.gitignore
vendored
@ -1,2 +1,3 @@
|
|||||||
node_modules
|
node_modules
|
||||||
dist
|
dist
|
||||||
|
.directory
|
||||||
|
Loading…
Reference in New Issue
Block a user