Skip to content

Commit

Permalink
back: fix missing token active check
Browse files Browse the repository at this point in the history
  • Loading branch information
Synar committed Nov 9, 2024
1 parent 09f330b commit 9c6f1ba
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
2 changes: 2 additions & 0 deletions backend/src/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ pub enum AppError {
Database(sqlx::Error),
InvalidPagination,
Internal(Option<String>),
NotFound,
}

#[derive(FromRequest)]
Expand Down Expand Up @@ -226,6 +227,7 @@ impl IntoResponse for AppError {
AppError::BadUsernameOrPassword => (StatusCode::NOT_FOUND, "user_not_found", None),
AppError::TokenValidation => (StatusCode::UNAUTHORIZED, "token_validation_error", None),
AppError::Validation(ve) => (StatusCode::BAD_REQUEST, "validation_error", Some(ve)),
AppError::NotFound => (StatusCode::NOT_FOUND, "not_found", None),
AppError::Database(de) => match de {
sqlx::Error::RowNotFound => (StatusCode::NOT_FOUND, "not_found", None),
_ => {
Expand Down
3 changes: 3 additions & 0 deletions backend/src/api/root.rs
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,9 @@ async fn bootstrap(
) -> Result<AppJson<BootstrapResponse>, AppError> {
tracing::trace!("Bootstrapping");
let access_token = AccessToken::get(token, &mut conn).await?;
if !access_token.active{
return Err(AppError::NotFound)
}

// Process the token request
let perms: crate::models::access_token::Permissions = access_token.permissions.0;
Expand Down

0 comments on commit 9c6f1ba

Please sign in to comment.