change: Rename DuplicatedUser error to AlreadyRegistered

Signed-off-by: Awiteb <a@4rs.nl>
This commit is contained in:
Awiteb 2024-07-12 23:23:16 +03:00
parent 927a345802
commit abbdec49e7
Signed by: awiteb
GPG key ID: 3F6B55640AA6682F
2 changed files with 3 additions and 3 deletions

View file

@ -53,7 +53,7 @@ impl UserTableExt for DatabaseConnection {
.await .await
{ {
if let Some(SqlErr::UniqueConstraintViolation(_)) = err.sql_err() { if let Some(SqlErr::UniqueConstraintViolation(_)) = err.sql_err() {
return Err(ApiError::DuplicatedUser); return Err(ApiError::AlreadyRegistered);
} }
} }

View file

@ -48,7 +48,7 @@ pub enum ApiError {
RegistrationClosed, RegistrationClosed,
/// The entered public key is already registered (400 Bad Request) /// The entered public key is already registered (400 Bad Request)
#[error("The entered public key is already registered")] #[error("The entered public key is already registered")]
DuplicatedUser, AlreadyRegistered,
/// The user entered two different public keys /// The user entered two different public keys
/// one in the header and other in the request body /// one in the header and other in the request body
/// (400 Bad Request) /// (400 Bad Request)
@ -62,7 +62,7 @@ impl ApiError {
match self { match self {
Self::SeaOrm(_) => StatusCode::INTERNAL_SERVER_ERROR, Self::SeaOrm(_) => StatusCode::INTERNAL_SERVER_ERROR,
Self::RegistrationClosed => StatusCode::FORBIDDEN, Self::RegistrationClosed => StatusCode::FORBIDDEN,
Self::DuplicatedUser | Self::TwoDifferentKeys => StatusCode::BAD_REQUEST, Self::AlreadyRegistered | Self::TwoDifferentKeys => StatusCode::BAD_REQUEST,
} }
} }
} }