redirect to /login and redirect back, instead of showing small msg
This commit is contained in:
@@ -9,12 +9,14 @@ use crate::{
|
||||
error::CompositeError,
|
||||
logs::LogEntry,
|
||||
users::{User, auth::UserAuthenticate, permissions::Permission},
|
||||
web::{RedirectViaError, components::nav::nav, icons, pages::base},
|
||||
web::{components::nav::nav, icons, pages::base},
|
||||
};
|
||||
|
||||
pub async fn page(req: Request) -> Result<Response, CompositeError> {
|
||||
let u = User::authenticate(req.headers())?
|
||||
.ok_or(RedirectViaError(Redirect::to("/login?re=/logs")))?;
|
||||
let u = match User::authenticate(req.headers())? {
|
||||
Some(u) => u,
|
||||
None => return Ok(Redirect::to(&format!("/login?r={}", req.uri().path())).into_response()),
|
||||
};
|
||||
let mut conn = database::conn()?;
|
||||
let tx = conn.transaction()?;
|
||||
let logs = LogEntry::get_all(&tx)?;
|
||||
@@ -63,7 +65,7 @@ pub async fn page(req: Request) -> Result<Response, CompositeError> {
|
||||
}
|
||||
}
|
||||
} @else {
|
||||
p class="text-center p-2" {"You must have permission to view this page."}
|
||||
p class="text-center p-2" {"You must have permission to view logs."}
|
||||
}
|
||||
),
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user