mirror of
				https://gitlab.com/comunic/comunicapiv3
				synced 2025-10-30 23:24:42 +00:00 
			
		
		
		
	Can create admin reset token from command line
This commit is contained in:
		
							
								
								
									
										22
									
								
								src/main.rs
									
									
									
									
									
								
							
							
						
						
									
										22
									
								
								src/main.rs
									
									
									
									
									
								
							| @@ -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(()) | ||||
| } | ||||
		Reference in New Issue
	
	Block a user