1
0
mirror of https://gitlab.com/comunic/comunicapiv3 synced 2024-11-22 13:29:21 +00:00

Recovery => Reset

This commit is contained in:
Pierre HUBERT 2021-07-13 17:40:03 +02:00
parent 8ade67d899
commit dd99d9e5e1
4 changed files with 9 additions and 9 deletions

View File

@ -3,11 +3,11 @@
//! @author Pierre Hubert //! @author Pierre Hubert
#[derive(serde::Serialize)] #[derive(serde::Serialize)]
pub struct AdminCreatedPasswordRecoveryLinkApi { pub struct AdminCreatedPasswordResetLinkApi {
url: String, url: String,
} }
impl AdminCreatedPasswordRecoveryLinkApi { impl AdminCreatedPasswordResetLinkApi {
pub fn new(url: String) -> Self { pub fn new(url: String) -> Self {
Self { url } Self { url }
} }

View File

@ -13,4 +13,4 @@ pub mod admin_res_create_account;
pub mod admin_log_api; pub mod admin_log_api;
pub mod admin_search_user_result_api; pub mod admin_search_user_result_api;
pub mod admin_user_info_api; pub mod admin_user_info_api;
pub mod admin_create_password_recovery_link_api; pub mod admin_create_password_reset_link_api;

View File

@ -2,7 +2,7 @@
//! //!
//! @author Pierre Hubert //! @author Pierre Hubert
use crate::api_data::admin::admin_create_password_recovery_link_api::AdminCreatedPasswordRecoveryLinkApi; use crate::api_data::admin::admin_create_password_reset_link_api::AdminCreatedPasswordResetLinkApi;
use crate::api_data::admin::admin_search_user_result_api::AdminSearchUserResult; use crate::api_data::admin::admin_search_user_result_api::AdminSearchUserResult;
use crate::api_data::admin::admin_user_info_api::AdminUserInfoAPI; use crate::api_data::admin::admin_user_info_api::AdminUserInfoAPI;
use crate::constants::admin::AdminRole; use crate::constants::admin::AdminRole;
@ -66,18 +66,18 @@ pub fn change_email_address(r: &mut HttpRequestHandler) -> RequestResult {
r.ok() r.ok()
} }
/// Create a password recovery link for a Comunic user /// Create a password reset link for a Comunic user
pub fn create_password_recovery_link(r: &mut HttpRequestHandler) -> RequestResult { pub fn create_password_reset_link(r: &mut HttpRequestHandler) -> RequestResult {
r.check_admin_has_role(AdminRole::MANAGE_USERS)?; r.check_admin_has_role(AdminRole::MANAGE_USERS)?;
let user_id = r.post_user_id("user_id")?; let user_id = r.post_user_id("user_id")?;
let user = user_helper::find_user_by_id(&user_id)?; let user = user_helper::find_user_by_id(&user_id)?;
let token = account_helper::generate_password_reset_token(&user_id)?; let token = account_helper::generate_password_reset_token(&user_id)?;
let recovery_link = conf().password_reset_url.replace("{TOKEN}", &token); let reset_link = conf().password_reset_url.replace("{TOKEN}", &token);
log_admin_action(r.admin_id()?, &r.remote_ip(), log_admin_action(r.admin_id()?, &r.remote_ip(),
AdminAction::CreatePasswordRecoveryLink { user_id, user_name: user.full_name() })?; AdminAction::CreatePasswordRecoveryLink { user_id, user_name: user.full_name() })?;
r.set_response(AdminCreatedPasswordRecoveryLinkApi::new(recovery_link)) r.set_response(AdminCreatedPasswordResetLinkApi::new(reset_link))
} }

View File

@ -399,6 +399,6 @@ pub fn get_routes() -> Vec<Route> {
Route::admin_post("/admin/users/search", Box::new(admin_users_controller::search)), Route::admin_post("/admin/users/search", Box::new(admin_users_controller::search)),
Route::admin_post("/admin/users/info", Box::new(admin_users_controller::get_single)), Route::admin_post("/admin/users/info", Box::new(admin_users_controller::get_single)),
Route::admin_post("/admin/users/change_email_address", Box::new(admin_users_controller::change_email_address)), Route::admin_post("/admin/users/change_email_address", Box::new(admin_users_controller::change_email_address)),
Route::admin_post("/admin/users/create_password_recovery_link", Box::new(admin_users_controller::create_password_recovery_link)), Route::admin_post("/admin/users/create_password_reset_link", Box::new(admin_users_controller::create_password_reset_link)),
] ]
} }