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

Return more information on successful reset token check

This commit is contained in:
Pierre HUBERT 2021-02-17 18:44:37 +01:00
parent 312e6fb949
commit 4a2784919b
3 changed files with 31 additions and 3 deletions

View File

@ -65,4 +65,5 @@ pub mod call_member_info;
pub mod left_call_message;
pub mod new_call_signal;
pub mod call_peer_ready;
pub mod call_peer_interrupted_streaming;
pub mod call_peer_interrupted_streaming;
pub mod res_check_password_token;

View File

@ -0,0 +1,24 @@
//! # Successful validation of password reset token
//!
//! @author Pierre Hubert
use serde::Serialize;
use crate::data::user::User;
#[derive(Serialize)]
pub struct ResCheckPasswordToken {
first_name: String,
last_name: String,
mail: String,
}
impl ResCheckPasswordToken {
pub fn new(user: &User) -> Self {
Self {
first_name: user.first_name.to_string(),
last_name: user.last_name.to_string(),
mail: user.email.to_string(),
}
}
}

View File

@ -4,6 +4,7 @@ use crate::api_data::account_export_api::AccountExportAPI;
use crate::api_data::current_user_id::CurrentUserID;
use crate::api_data::login_success::LoginSuccess;
use crate::api_data::res_check_email_exists::ResCheckEmailExists;
use crate::api_data::res_check_password_token::ResCheckPasswordToken;
use crate::api_data::res_check_security_answers::ResCheckSecurityAnswers;
use crate::api_data::res_check_security_questions_exists::ResCheckSecurityQuestionsExists;
use crate::api_data::res_get_security_questions::ResGetSecurityQuestions;
@ -171,8 +172,10 @@ pub fn check_security_answers(r: &mut HttpRequestHandler) -> RequestResult {
/// Check the validity of a password reset token
pub fn check_password_reset_token(r: &mut HttpRequestHandler) -> RequestResult {
r.post_user_id_from_password_reset_token("token")?;
r.success("The token is valid")
let user_id = r.post_user_id_from_password_reset_token("token")?;
let user = user_helper::find_user_by_id(&user_id)?;
r.set_response(ResCheckPasswordToken::new(&user))
}
/// Reset user password