diff --git a/src/main.rs b/src/main.rs index d9f6692..501e4db 100644 --- a/src/main.rs +++ b/src/main.rs @@ -48,6 +48,14 @@ fn get_actions() -> Vec { 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) -> Res { println!("* New admin ID: {}", id.id()); + Ok(()) +} + +fn create_admin_reset_token(args: Vec) -> 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(()) } \ No newline at end of file