forked from Ruderverein-Donau-Linz/rowt
send flash msg to /admin view
This commit is contained in:
parent
a2ca837a21
commit
253018580a
@ -2,19 +2,29 @@ use crate::model::user::{AdminUser, User};
|
|||||||
use rocket::{
|
use rocket::{
|
||||||
form::Form,
|
form::Form,
|
||||||
get, post,
|
get, post,
|
||||||
|
request::FlashMessage,
|
||||||
response::{Flash, Redirect},
|
response::{Flash, Redirect},
|
||||||
routes, FromForm, Route, State,
|
routes, FromForm, Route, State,
|
||||||
};
|
};
|
||||||
use rocket_dyn_templates::{context, Template};
|
use rocket_dyn_templates::{tera::Context, Template};
|
||||||
use sqlx::SqlitePool;
|
use sqlx::SqlitePool;
|
||||||
|
|
||||||
#[get("/user")]
|
#[get("/user")]
|
||||||
async fn index(db: &State<SqlitePool>, admin: AdminUser) -> Template {
|
async fn index(
|
||||||
|
db: &State<SqlitePool>,
|
||||||
|
admin: AdminUser,
|
||||||
|
flash: Option<FlashMessage<'_>>,
|
||||||
|
) -> Template {
|
||||||
let users = User::all(db).await;
|
let users = User::all(db).await;
|
||||||
Template::render(
|
|
||||||
"admin/user/index",
|
let mut context = Context::new();
|
||||||
context!(users, loggedin_user: admin.user),
|
if let Some(msg) = flash {
|
||||||
)
|
context.insert("flash", &msg.into_inner());
|
||||||
|
}
|
||||||
|
context.insert("users", &users);
|
||||||
|
context.insert("loggedin_user", &admin.user);
|
||||||
|
|
||||||
|
Template::render("admin/user/index", context.into_json())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[get("/user/<user>/reset-pw")]
|
#[get("/user/<user>/reset-pw")]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user