From dd99d9e5e1b1ea157418848f9db50cfee7a09eb2 Mon Sep 17 00:00:00 2001 From: Pierre HUBERT Date: Tue, 13 Jul 2021 17:40:03 +0200 Subject: [PATCH] Recovery => Reset --- ..._api.rs => admin_create_password_reset_link_api.rs} | 4 ++-- src/api_data/admin/mod.rs | 2 +- src/controllers/admin/admin_users_controller.rs | 10 +++++----- src/routes.rs | 2 +- 4 files changed, 9 insertions(+), 9 deletions(-) rename src/api_data/admin/{admin_create_password_recovery_link_api.rs => admin_create_password_reset_link_api.rs} (67%) diff --git a/src/api_data/admin/admin_create_password_recovery_link_api.rs b/src/api_data/admin/admin_create_password_reset_link_api.rs similarity index 67% rename from src/api_data/admin/admin_create_password_recovery_link_api.rs rename to src/api_data/admin/admin_create_password_reset_link_api.rs index 6c81a62..751e60f 100644 --- a/src/api_data/admin/admin_create_password_recovery_link_api.rs +++ b/src/api_data/admin/admin_create_password_reset_link_api.rs @@ -3,11 +3,11 @@ //! @author Pierre Hubert #[derive(serde::Serialize)] -pub struct AdminCreatedPasswordRecoveryLinkApi { +pub struct AdminCreatedPasswordResetLinkApi { url: String, } -impl AdminCreatedPasswordRecoveryLinkApi { +impl AdminCreatedPasswordResetLinkApi { pub fn new(url: String) -> Self { Self { url } } diff --git a/src/api_data/admin/mod.rs b/src/api_data/admin/mod.rs index 48780c4..ad4bb73 100644 --- a/src/api_data/admin/mod.rs +++ b/src/api_data/admin/mod.rs @@ -13,4 +13,4 @@ pub mod admin_res_create_account; pub mod admin_log_api; pub mod admin_search_user_result_api; pub mod admin_user_info_api; -pub mod admin_create_password_recovery_link_api; \ No newline at end of file +pub mod admin_create_password_reset_link_api; \ No newline at end of file diff --git a/src/controllers/admin/admin_users_controller.rs b/src/controllers/admin/admin_users_controller.rs index e420e60..94dc72a 100644 --- a/src/controllers/admin/admin_users_controller.rs +++ b/src/controllers/admin/admin_users_controller.rs @@ -2,7 +2,7 @@ //! //! @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_user_info_api::AdminUserInfoAPI; use crate::constants::admin::AdminRole; @@ -66,18 +66,18 @@ pub fn change_email_address(r: &mut HttpRequestHandler) -> RequestResult { r.ok() } -/// Create a password recovery link for a Comunic user -pub fn create_password_recovery_link(r: &mut HttpRequestHandler) -> RequestResult { +/// Create a password reset link for a Comunic user +pub fn create_password_reset_link(r: &mut HttpRequestHandler) -> RequestResult { r.check_admin_has_role(AdminRole::MANAGE_USERS)?; let user_id = r.post_user_id("user_id")?; let user = user_helper::find_user_by_id(&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(), AdminAction::CreatePasswordRecoveryLink { user_id, user_name: user.full_name() })?; - r.set_response(AdminCreatedPasswordRecoveryLinkApi::new(recovery_link)) + r.set_response(AdminCreatedPasswordResetLinkApi::new(reset_link)) } \ No newline at end of file diff --git a/src/routes.rs b/src/routes.rs index ed7b307..29c8449 100644 --- a/src/routes.rs +++ b/src/routes.rs @@ -399,6 +399,6 @@ pub fn get_routes() -> Vec { 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/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)), ] } \ No newline at end of file