2022-01-13 11:16:38 +00:00
|
|
|
use rocket::{get, request::FlashMessage};
|
|
|
|
use rocket_dyn_templates::{tera::Context, Template};
|
2021-11-15 15:32:00 +00:00
|
|
|
|
|
|
|
use crate::routes::authentication::Authenticated;
|
|
|
|
|
|
|
|
// HELPERS AND ROUTES FOR /settings
|
|
|
|
|
|
|
|
/// View and delete currently configured admin.
|
|
|
|
#[get("/settings")]
|
|
|
|
pub fn settings_menu(flash: Option<FlashMessage>, _auth: Authenticated) -> Template {
|
2022-01-13 11:16:38 +00:00
|
|
|
let mut context = Context::new();
|
|
|
|
context.insert("back", &Some("/".to_string()));
|
|
|
|
context.insert("title", &Some("Settings".to_string()));
|
|
|
|
|
2021-11-15 15:32:00 +00:00
|
|
|
// check to see if there is a flash message to display
|
|
|
|
if let Some(flash) = flash {
|
2022-01-13 11:16:38 +00:00
|
|
|
context.insert("flash_name", &Some(flash.kind().to_string()));
|
|
|
|
context.insert("flash_msg", &Some(flash.message().to_string()));
|
2021-11-15 15:32:00 +00:00
|
|
|
};
|
2022-01-13 11:16:38 +00:00
|
|
|
|
|
|
|
Template::render("settings/menu", &context.into_json())
|
2021-11-15 15:32:00 +00:00
|
|
|
}
|