ezidam: oauth: redirect: check if user is archived

This commit is contained in:
Philippe Loctaux 2023-03-18 13:44:17 +01:00
parent e9200f8682
commit 609933d98f
2 changed files with 9 additions and 0 deletions

View file

@ -47,4 +47,8 @@ impl Error {
pub fn bad_request<M: std::fmt::Display>(value: M) -> Self {
Self::new(Status::BadRequest, value)
}
pub fn forbidden<M: std::fmt::Display>(value: M) -> Self {
Self::new(Status::Forbidden, value)
}
}

View file

@ -40,6 +40,11 @@ pub async fn redirect_page(
.await?
.ok_or_else(|| Error::not_found("Could not find user"))?;
// Check if user is archived
if user.is_archived() {
return Err(Error::forbidden("User is archived"));
}
// Mark code as used
code.use_code(&mut transaction).await?;