Remove Role::from_name function
This commit is contained in:
parent
21135d7704
commit
3b5c8a4131
2 changed files with 6 additions and 11 deletions
|
@ -196,7 +196,12 @@ impl SetRole {
|
|||
&self,
|
||||
db_client: &impl DatabaseClient,
|
||||
) -> Result<(), Error> {
|
||||
let role = Role::from_name(&self.role)?;
|
||||
let role = match self.role.as_str() {
|
||||
"user" => Role::NormalUser,
|
||||
"admin" => Role::Admin,
|
||||
"read_only_user" => Role::ReadOnlyUser,
|
||||
_ => return Err(anyhow!("unknown role")),
|
||||
};
|
||||
set_user_role(db_client, &self.id, role).await?;
|
||||
println!("role changed");
|
||||
Ok(())
|
||||
|
|
|
@ -47,16 +47,6 @@ impl Default for Role {
|
|||
}
|
||||
|
||||
impl Role {
|
||||
pub fn from_name(name: &str) -> Result<Self, ValidationError> {
|
||||
let role = match name {
|
||||
"user" => Self::NormalUser,
|
||||
"admin" => Self::Admin,
|
||||
"read_only_user" => Self::ReadOnlyUser,
|
||||
_ => return Err(ValidationError("unknown role")),
|
||||
};
|
||||
Ok(role)
|
||||
}
|
||||
|
||||
pub fn get_permissions(&self) -> Vec<Permission> {
|
||||
match self {
|
||||
Self::Guest => vec![],
|
||||
|
|
Loading…
Reference in a new issue