forked from jmug/stoatchat
refactor(core/result): add NotAuthenticated error which is distinct from InvalidCredentials
This commit is contained in:
@@ -70,7 +70,7 @@ impl Webhook {
|
|||||||
if self.token.as_deref() == Some(token) {
|
if self.token.as_deref() == Some(token) {
|
||||||
Ok(())
|
Ok(())
|
||||||
} else {
|
} else {
|
||||||
Err(create_error!(InvalidCredentials))
|
Err(create_error!(NotAuthenticated))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ impl FromRequestParts<Database> for User {
|
|||||||
let session = db.fetch_session_by_token(session_token).await?;
|
let session = db.fetch_session_by_token(session_token).await?;
|
||||||
db.fetch_user(&session.user_id).await
|
db.fetch_user(&session.user_id).await
|
||||||
} else {
|
} else {
|
||||||
Err(create_error!(InvalidCredentials))
|
Err(create_error!(NotAuthenticated))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -67,6 +67,7 @@ impl IntoResponse for Error {
|
|||||||
ErrorType::InvalidCredentials => StatusCode::UNAUTHORIZED,
|
ErrorType::InvalidCredentials => StatusCode::UNAUTHORIZED,
|
||||||
ErrorType::InvalidProperty => StatusCode::BAD_REQUEST,
|
ErrorType::InvalidProperty => StatusCode::BAD_REQUEST,
|
||||||
ErrorType::InvalidSession => StatusCode::UNAUTHORIZED,
|
ErrorType::InvalidSession => StatusCode::UNAUTHORIZED,
|
||||||
|
ErrorType::NotAuthenticated => StatusCode::UNAUTHORIZED,
|
||||||
ErrorType::DuplicateNonce => StatusCode::CONFLICT,
|
ErrorType::DuplicateNonce => StatusCode::CONFLICT,
|
||||||
ErrorType::VosoUnavailable => StatusCode::BAD_REQUEST,
|
ErrorType::VosoUnavailable => StatusCode::BAD_REQUEST,
|
||||||
ErrorType::NotFound => StatusCode::NOT_FOUND,
|
ErrorType::NotFound => StatusCode::NOT_FOUND,
|
||||||
|
|||||||
@@ -147,6 +147,7 @@ pub enum ErrorType {
|
|||||||
InvalidCredentials,
|
InvalidCredentials,
|
||||||
InvalidProperty,
|
InvalidProperty,
|
||||||
InvalidSession,
|
InvalidSession,
|
||||||
|
NotAuthenticated,
|
||||||
DuplicateNonce,
|
DuplicateNonce,
|
||||||
NotFound,
|
NotFound,
|
||||||
NoEffect,
|
NoEffect,
|
||||||
|
|||||||
@@ -73,6 +73,7 @@ impl<'r> Responder<'r, 'static> for Error {
|
|||||||
ErrorType::InvalidCredentials => Status::Unauthorized,
|
ErrorType::InvalidCredentials => Status::Unauthorized,
|
||||||
ErrorType::InvalidProperty => Status::BadRequest,
|
ErrorType::InvalidProperty => Status::BadRequest,
|
||||||
ErrorType::InvalidSession => Status::Unauthorized,
|
ErrorType::InvalidSession => Status::Unauthorized,
|
||||||
|
ErrorType::NotAuthenticated => Status::Unauthorized,
|
||||||
ErrorType::DuplicateNonce => Status::Conflict,
|
ErrorType::DuplicateNonce => Status::Conflict,
|
||||||
ErrorType::VosoUnavailable => Status::BadRequest,
|
ErrorType::VosoUnavailable => Status::BadRequest,
|
||||||
ErrorType::NotFound => Status::NotFound,
|
ErrorType::NotFound => Status::NotFound,
|
||||||
|
|||||||
Reference in New Issue
Block a user