1
0
mirror of https://gitlab.com/comunic/comunicapiv3 synced 2024-11-25 23:09:22 +00:00

Can create admin reset token from command line

This commit is contained in:
Pierre HUBERT 2021-05-08 19:22:47 +02:00
parent c0489613fb
commit 56539d3476

View File

@ -48,6 +48,14 @@ fn get_actions() -> Vec<Action> {
arguments: vec!["name".to_string(), "email".to_string()],
function: Box::new(create_admin),
},
// Create a reset token for an admin
Action {
name: "create_admin_reset_token".to_string(),
description: "Create a new reset token to register a new access key to an admin account".to_string(),
arguments: vec!["email".to_string()],
function: Box::new(create_admin_reset_token),
},
]
}
@ -170,5 +178,19 @@ fn create_admin(args: Vec<String>) -> Res {
println!("* New admin ID: {}", id.id());
Ok(())
}
fn create_admin_reset_token(args: Vec<String>) -> Res {
let admin = admin_account_helper::find_admin_by_email(&args[0])
.expect("Failed to load admin information!");
println!("Generate a new reset token for {} ({})", admin.name, admin.email);
let token = admin_account_helper::create_new_reset_token(admin.id)
.expect("Failed to create admin reset token!");
println!("Reset token: {}", token.token);
Ok(())
}