test wiki auth
This commit is contained in:
		| @@ -1,11 +1,12 @@ | ||||
| use rocket::{ | ||||
|     catch, catchers, | ||||
|     fairing::AdHoc, | ||||
|     form::Form, | ||||
|     fs::FileServer, | ||||
|     get, | ||||
|     get, post, | ||||
|     request::FlashMessage, | ||||
|     response::{Flash, Redirect}, | ||||
|     routes, Build, Rocket, State, | ||||
|     routes, Build, FromForm, Rocket, State, | ||||
| }; | ||||
| use rocket_dyn_templates::{tera::Context, Template}; | ||||
| use serde::Deserialize; | ||||
| @@ -27,6 +28,20 @@ mod log; | ||||
| mod misc; | ||||
| mod stat; | ||||
|  | ||||
| #[derive(FromForm)] | ||||
| struct LoginForm<'r> { | ||||
|     name: &'r str, | ||||
|     password: &'r str, | ||||
| } | ||||
|  | ||||
| #[post("/", data = "<login>")] | ||||
| async fn wikiauth(db: &State<SqlitePool>, login: Form<LoginForm<'_>>) -> String { | ||||
|     match User::login(db, login.name, login.password).await { | ||||
|         Ok(_) => "SUCC".into(), | ||||
|         Err(_) => "FAIL".into(), | ||||
|     } | ||||
| } | ||||
|  | ||||
| #[get("/")] | ||||
| async fn index(db: &State<SqlitePool>, user: User, flash: Option<FlashMessage<'_>>) -> Template { | ||||
|     let mut context = Context::new(); | ||||
| @@ -195,6 +210,7 @@ pub fn config(rocket: Rocket<Build>) -> Rocket<Build> { | ||||
|     rocket | ||||
|         .mount("/", routes![index, join, remove, remove_guest]) | ||||
|         .mount("/auth", auth::routes()) | ||||
|         .mount("/wikiauth", routes![wikiauth]) | ||||
|         .mount("/log", log::routes()) | ||||
|         .mount("/stat", stat::routes()) | ||||
|         .mount("/boatdamage", boatdamage::routes()) | ||||
|   | ||||
		Reference in New Issue
	
	Block a user