Rename SessionError to AuthError

This commit is contained in:
silverpill 2021-12-03 18:15:53 +00:00
parent 057cac1ac7
commit c5e292d39f
2 changed files with 3 additions and 3 deletions

View file

@ -47,7 +47,7 @@ pub enum HttpError {
ValidationErrorAuto(#[from] ValidationError),
#[error("{0}")]
SessionError(&'static str),
AuthError(&'static str),
#[error("permission error")]
PermissionError,
@ -93,7 +93,7 @@ impl ResponseError for HttpError {
HttpError::ActixError(err) => err.as_response_error().status_code(),
HttpError::ValidationError(_) => StatusCode::BAD_REQUEST,
HttpError::ValidationErrorAuto(_) => StatusCode::BAD_REQUEST,
HttpError::SessionError(_) => StatusCode::UNAUTHORIZED,
HttpError::AuthError(_) => StatusCode::UNAUTHORIZED,
HttpError::PermissionError => StatusCode::FORBIDDEN,
HttpError::NotFoundError(_) => StatusCode::NOT_FOUND,
HttpError::NotSupported => StatusCode::IM_A_TEAPOT,

View file

@ -18,7 +18,7 @@ pub async fn get_current_user(
let user = get_user_by_oauth_token(db_client, token).await.map_err(|err| {
match err {
DatabaseError::NotFound(_) => {
HttpError::SessionError("access token is invalid")
HttpError::AuthError("access token is invalid")
},
_ => HttpError::InternalError,
}