mirror of
https://gitlab.com/comunic/comunicapiv3
synced 2024-12-26 13:38:51 +00:00
Recovery => Reset
This commit is contained in:
parent
8ade67d899
commit
dd99d9e5e1
@ -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 }
|
||||
}
|
@ -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;
|
||||
pub mod admin_create_password_reset_link_api;
|
@ -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))
|
||||
}
|
@ -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/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)),
|
||||
]
|
||||
}
|
Loading…
Reference in New Issue
Block a user