eeg_certs/backend/src/online_classroom/users.rs

26 lines
816 B
Rust
Raw Normal View History

use rocket::{http::Status, serde::json::Json};
2023-09-25 22:26:00 +00:00
use super::{json_result::JsonResult, session::request};
// Instead of requesting pages and managing session & cookies manually,
// create a wrapper that:
// - Checks if the session cookie is valid
// - If not, tries to login
// - Makes the request
// - Returns the html string, or an error
#[get("/classroom/users/<full_name>")]
pub async fn get_users(full_name: String) -> (Status, Json<JsonResult<()>>) {
2023-09-25 22:26:00 +00:00
let html = request(format!("/main/admin/user_list.php?keyword={}&submit=&_qf__search_simple=", full_name)).await;
match html {
Ok(html) => {
println!("{}", html);
(Status::Ok, JsonResult::ok(()))
}
Err(reason) => {
(Status::InternalServerError, JsonResult::err(reason))
}
}
}