simple-nx-auth #924
@ -123,6 +123,19 @@ async fn wikiauth(db: &State<SqlitePool>, login: Form<LoginForm<'_>>) -> String
|
|||||||
"FAIL".into()
|
"FAIL".into()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[post("/", data = "<login>")]
|
||||||
|
async fn nextcloud_auth(db: &State<SqlitePool>, login: Form<LoginForm<'_>>) -> String {
|
||||||
|
if let Ok(user) = User::login(db, login.name, login.password).await {
|
||||||
|
if user.has_role(db, "admin").await {
|
||||||
|
return String::from("SUCC");
|
||||||
|
}
|
||||||
|
if user.has_role(db, "Vorstand").await {
|
||||||
|
return String::from("SUCC");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
"FAIL".into()
|
||||||
|
}
|
||||||
|
|
||||||
#[catch(401)] //Unauthorized
|
#[catch(401)] //Unauthorized
|
||||||
fn unauthorized_error(req: &Request) -> Redirect {
|
fn unauthorized_error(req: &Request) -> Redirect {
|
||||||
// Save the URL the user tried to access, to be able to go there once logged in
|
// Save the URL the user tried to access, to be able to go there once logged in
|
||||||
@ -264,6 +277,7 @@ pub fn config(rocket: Rocket<Build>) -> Rocket<Build> {
|
|||||||
.mount("/", routes![index, steering, impressum])
|
.mount("/", routes![index, steering, impressum])
|
||||||
.mount("/auth", auth::routes())
|
.mount("/auth", auth::routes())
|
||||||
.mount("/wikiauth", routes![wikiauth])
|
.mount("/wikiauth", routes![wikiauth])
|
||||||
|
.mount("/nxauth", routes![nextcloud_auth])
|
||||||
.mount("/new-blogpost", routes![new_blogpost])
|
.mount("/new-blogpost", routes![new_blogpost])
|
||||||
.mount("/blogpost-unpublished", routes![blogpost_unpublished])
|
.mount("/blogpost-unpublished", routes![blogpost_unpublished])
|
||||||
.mount("/log", log::routes())
|
.mount("/log", log::routes())
|
||||||
|
Loading…
x
Reference in New Issue
Block a user