Merge branch 'staging' into 'main'
Staging See merge request PhilippHofer/rot!45
This commit is contained in:
commit
415bc45f2e
@ -1,11 +1,12 @@
|
|||||||
use rocket::{
|
use rocket::{
|
||||||
catch, catchers,
|
catch, catchers,
|
||||||
fairing::AdHoc,
|
fairing::AdHoc,
|
||||||
|
form::Form,
|
||||||
fs::FileServer,
|
fs::FileServer,
|
||||||
get,
|
get, post,
|
||||||
request::FlashMessage,
|
request::FlashMessage,
|
||||||
response::{Flash, Redirect},
|
response::{Flash, Redirect},
|
||||||
routes, Build, Rocket, State,
|
routes, Build, FromForm, Rocket, State,
|
||||||
};
|
};
|
||||||
use rocket_dyn_templates::{tera::Context, Template};
|
use rocket_dyn_templates::{tera::Context, Template};
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
@ -27,6 +28,20 @@ mod log;
|
|||||||
mod misc;
|
mod misc;
|
||||||
mod stat;
|
mod stat;
|
||||||
|
|
||||||
|
#[derive(FromForm, Debug)]
|
||||||
|
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("/")]
|
#[get("/")]
|
||||||
async fn index(db: &State<SqlitePool>, user: User, flash: Option<FlashMessage<'_>>) -> Template {
|
async fn index(db: &State<SqlitePool>, user: User, flash: Option<FlashMessage<'_>>) -> Template {
|
||||||
let mut context = Context::new();
|
let mut context = Context::new();
|
||||||
@ -195,6 +210,7 @@ pub fn config(rocket: Rocket<Build>) -> Rocket<Build> {
|
|||||||
rocket
|
rocket
|
||||||
.mount("/", routes![index, join, remove, remove_guest])
|
.mount("/", routes![index, join, remove, remove_guest])
|
||||||
.mount("/auth", auth::routes())
|
.mount("/auth", auth::routes())
|
||||||
|
.mount("/wikiauth", routes![wikiauth])
|
||||||
.mount("/log", log::routes())
|
.mount("/log", log::routes())
|
||||||
.mount("/stat", stat::routes())
|
.mount("/stat", stat::routes())
|
||||||
.mount("/boatdamage", boatdamage::routes())
|
.mount("/boatdamage", boatdamage::routes())
|
||||||
|
Loading…
Reference in New Issue
Block a user