ezidam: empty admin dashboard, link for admins to access it
This commit is contained in:
parent
3f0b09008c
commit
ddf6f25dd2
7 changed files with 46 additions and 1 deletions
|
|
@ -15,6 +15,7 @@ pub enum Page {
|
|||
Homepage(Homepage),
|
||||
Authorize(Authorize),
|
||||
Redirect(Redirect),
|
||||
AdminDashboard(AdminDashboard),
|
||||
}
|
||||
|
||||
impl Page {
|
||||
|
|
@ -26,6 +27,7 @@ impl Page {
|
|||
Page::Homepage(_) => "pages/homepage",
|
||||
Page::Authorize(_) => "pages/oauth/authorize",
|
||||
Page::Redirect(_) => "pages/oauth/redirect",
|
||||
Page::AdminDashboard(_) => "pages/admin/dashboard",
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -37,6 +39,7 @@ impl Page {
|
|||
Page::Homepage(_) => "Home",
|
||||
Page::Authorize(_) => "Authorize app",
|
||||
Page::Redirect(_) => "Redirecting",
|
||||
Page::AdminDashboard(_) => "Admin dashboard",
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -51,6 +54,7 @@ impl Page {
|
|||
Page::Homepage(_) => Some(UserMenu::Home.into()),
|
||||
Page::Authorize(_) => None,
|
||||
Page::Redirect(_) => None,
|
||||
Page::AdminDashboard(_) => Some(AdminMenu::AdminDashboard.into()),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -62,6 +66,7 @@ impl Page {
|
|||
Page::Homepage(homepage) => Box::new(homepage),
|
||||
Page::Authorize(authorize) => Box::new(authorize),
|
||||
Page::Redirect(redirect) => Box::new(redirect),
|
||||
Page::AdminDashboard(dashboard) => Box::new(dashboard),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
pub use crate::error::content::*;
|
||||
pub use crate::routes::admin::content::*;
|
||||
pub use crate::routes::oauth::content::*;
|
||||
pub use crate::routes::root::content::*;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
use rocket::{Build, Rocket};
|
||||
|
||||
pub mod admin;
|
||||
pub mod oauth;
|
||||
pub mod root;
|
||||
pub mod setup;
|
||||
|
|
@ -39,4 +40,6 @@ pub fn routes(rocket_builder: Rocket<Build>) -> Rocket<Build> {
|
|||
.mount("/", oauth::routes())
|
||||
// Well known
|
||||
.mount("/", well_known::routes())
|
||||
// Admin
|
||||
.mount("/", admin::routes())
|
||||
}
|
||||
|
|
|
|||
20
crates/ezidam/src/routes/admin.rs
Normal file
20
crates/ezidam/src/routes/admin.rs
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
use dashboard::*;
|
||||
use rocket::{routes, Route};
|
||||
|
||||
pub mod dashboard;
|
||||
|
||||
pub fn routes() -> Vec<Route> {
|
||||
routes![admin_dashboard]
|
||||
}
|
||||
|
||||
pub mod content {
|
||||
use jwt::JwtClaims;
|
||||
use rocket::serde::Serialize;
|
||||
|
||||
#[derive(Serialize)]
|
||||
#[serde(crate = "rocket::serde")]
|
||||
#[derive(Clone)]
|
||||
pub struct AdminDashboard {
|
||||
pub user: JwtClaims,
|
||||
}
|
||||
}
|
||||
9
crates/ezidam/src/routes/admin/dashboard.rs
Normal file
9
crates/ezidam/src/routes/admin/dashboard.rs
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
use crate::routes::prelude::*;
|
||||
use rocket::get;
|
||||
|
||||
#[get("/admin")]
|
||||
pub async fn admin_dashboard(mut db: Connection<Database>, admin: JwtAdmin) -> Result<Page> {
|
||||
Ok(Page::AdminDashboard(super::content::AdminDashboard {
|
||||
user: admin.0,
|
||||
}))
|
||||
}
|
||||
4
crates/ezidam/templates/pages/admin/dashboard.html.tera
Normal file
4
crates/ezidam/templates/pages/admin/dashboard.html.tera
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
{% extends "shell" %}
|
||||
|
||||
{% block content %}
|
||||
{% endblock content %}
|
||||
|
|
@ -35,7 +35,10 @@
|
|||
</div>
|
||||
</a>
|
||||
<div class="dropdown-menu dropdown-menu-end dropdown-menu-arrow">
|
||||
<a href="./settings" class="dropdown-item">Settings</a>
|
||||
{% if user.isAdmin == true %}
|
||||
<a href="/admin" class="dropdown-item">Admin panel</a>
|
||||
{% endif %}
|
||||
<a href="/settings" class="dropdown-item">Settings</a>
|
||||
<div class="dropdown-divider"></div>
|
||||
<form action="/logout" method="post">
|
||||
<button type="submit" class="dropdown-item">Logout</button>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue