Create authentication request guard #17

Merged
notplants merged 7 commits from auth into main 2021-11-10 11:35:47 +00:00
2 changed files with 3 additions and 5 deletions
Showing only changes of commit 18fbb7fa5f - Show all commits

View File

@ -30,9 +30,7 @@ pub struct Authenticated {
#[derive(Debug)]
pub enum LoginError {
InvalidData,
UsernameDoesNotExist,
WrongPassword
UserNotLoggedIn
}
/// Request guard which returns an Authenticated struct with is_authenticated=true
@ -55,7 +53,7 @@ impl<'r> FromRequest<'r> for Authenticated {
request::Outcome::Success(auth)
},
None => {
request::Outcome::Failure((Status::Forbidden, LoginError::UsernameDoesNotExist))
request::Outcome::Failure((Status::Forbidden, LoginError::UserNotLoggedIn))
}
}
}

View File

@ -51,7 +51,7 @@ pub fn internal_error() -> Template {
Template::render("internal_error", context)
}
// HELPERS AND ROUNTES FOR 403 FORBIDDEN
// HELPERS AND ROUTES FOR 403 FORBIDDEN
#[catch(403)]
pub fn forbidden() -> Redirect {