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::{
|
||||
form::Form,
|
||||
get, post,
|
||||
request::FlashMessage,
|
||||
response::{Flash, Redirect},
|
||||
routes, FromForm, Route, State,
|
||||
};
|
||||
use rocket_dyn_templates::{context, Template};
|
||||
use rocket_dyn_templates::{tera::Context, Template};
|
||||
use sqlx::SqlitePool;
|
||||
|
||||
#[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;
|
||||
Template::render(
|
||||
"admin/user/index",
|
||||
context!(users, loggedin_user: admin.user),
|
||||
)
|
||||
|
||||
let mut context = Context::new();
|
||||
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")]
|
||||
|
Loading…
x
Reference in New Issue
Block a user