feat(otter): cli command to toggle admin status
This commit is contained in:
parent
ee9db5ae36
commit
b946e1ce98
6 changed files with 50 additions and 2 deletions
|
|
@ -1,4 +1,4 @@
|
|||
use clap::{Args, Subcommand};
|
||||
use clap::{ArgAction, Args, Subcommand};
|
||||
|
||||
use super::CliError;
|
||||
|
||||
|
|
@ -22,6 +22,12 @@ pub enum UserCommand {
|
|||
Add { username: String, password: String },
|
||||
/// Generate a signup link ID
|
||||
GenerateSignupLink,
|
||||
/// Give or remove admin privileges to a user
|
||||
SetAdmin {
|
||||
username: String,
|
||||
#[clap(action=ArgAction::Set)]
|
||||
is_admin: bool,
|
||||
},
|
||||
}
|
||||
|
||||
impl Command {
|
||||
|
|
@ -67,6 +73,11 @@ impl UserCommand {
|
|||
|
||||
println!("/signup/{}", link.id);
|
||||
}
|
||||
Self::SetAdmin { username, is_admin } => {
|
||||
let mut user = store.get_user(username)?;
|
||||
user.admin = *is_admin;
|
||||
store.update_user(user)?;
|
||||
}
|
||||
}
|
||||
|
||||
Ok(())
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue