core: move DbOrUser to types, wrap item name in struct
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::core::{
|
||||
protocol::request_validation::{DbOrUser, NameValidationError, OwnerValidationError},
|
||||
types::MySQLUser,
|
||||
protocol::request_validation::{NameValidationError, OwnerValidationError},
|
||||
types::{DbOrUser, MySQLUser},
|
||||
};
|
||||
|
||||
pub type SetUserPasswordRequest = (MySQLUser, String);
|
||||
@@ -33,9 +33,11 @@ impl SetPasswordError {
|
||||
pub fn to_error_message(&self, username: &MySQLUser) -> String {
|
||||
match self {
|
||||
SetPasswordError::SanitizationError(err) => {
|
||||
err.to_error_message(username, DbOrUser::User)
|
||||
err.to_error_message(DbOrUser::User(username.clone()))
|
||||
}
|
||||
SetPasswordError::OwnershipError(err) => {
|
||||
err.to_error_message(DbOrUser::User(username.clone()))
|
||||
}
|
||||
SetPasswordError::OwnershipError(err) => err.to_error_message(username, DbOrUser::User),
|
||||
SetPasswordError::UserDoesNotExist => {
|
||||
format!("User '{}' does not exist.", username)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user