Rename SessionError to AuthError
This commit is contained in:
parent
057cac1ac7
commit
c5e292d39f
2 changed files with 3 additions and 3 deletions
|
@ -47,7 +47,7 @@ pub enum HttpError {
|
||||||
ValidationErrorAuto(#[from] ValidationError),
|
ValidationErrorAuto(#[from] ValidationError),
|
||||||
|
|
||||||
#[error("{0}")]
|
#[error("{0}")]
|
||||||
SessionError(&'static str),
|
AuthError(&'static str),
|
||||||
|
|
||||||
#[error("permission error")]
|
#[error("permission error")]
|
||||||
PermissionError,
|
PermissionError,
|
||||||
|
@ -93,7 +93,7 @@ impl ResponseError for HttpError {
|
||||||
HttpError::ActixError(err) => err.as_response_error().status_code(),
|
HttpError::ActixError(err) => err.as_response_error().status_code(),
|
||||||
HttpError::ValidationError(_) => StatusCode::BAD_REQUEST,
|
HttpError::ValidationError(_) => StatusCode::BAD_REQUEST,
|
||||||
HttpError::ValidationErrorAuto(_) => StatusCode::BAD_REQUEST,
|
HttpError::ValidationErrorAuto(_) => StatusCode::BAD_REQUEST,
|
||||||
HttpError::SessionError(_) => StatusCode::UNAUTHORIZED,
|
HttpError::AuthError(_) => StatusCode::UNAUTHORIZED,
|
||||||
HttpError::PermissionError => StatusCode::FORBIDDEN,
|
HttpError::PermissionError => StatusCode::FORBIDDEN,
|
||||||
HttpError::NotFoundError(_) => StatusCode::NOT_FOUND,
|
HttpError::NotFoundError(_) => StatusCode::NOT_FOUND,
|
||||||
HttpError::NotSupported => StatusCode::IM_A_TEAPOT,
|
HttpError::NotSupported => StatusCode::IM_A_TEAPOT,
|
||||||
|
|
|
@ -18,7 +18,7 @@ pub async fn get_current_user(
|
||||||
let user = get_user_by_oauth_token(db_client, token).await.map_err(|err| {
|
let user = get_user_by_oauth_token(db_client, token).await.map_err(|err| {
|
||||||
match err {
|
match err {
|
||||||
DatabaseError::NotFound(_) => {
|
DatabaseError::NotFound(_) => {
|
||||||
HttpError::SessionError("access token is invalid")
|
HttpError::AuthError("access token is invalid")
|
||||||
},
|
},
|
||||||
_ => HttpError::InternalError,
|
_ => HttpError::InternalError,
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue