mirror of
https://gitlab.com/comunic/comunicapiv3
synced 2024-11-26 07:19:22 +00:00
Return more information on successful reset token check
This commit is contained in:
parent
312e6fb949
commit
4a2784919b
@ -66,3 +66,4 @@ pub mod left_call_message;
|
||||
pub mod new_call_signal;
|
||||
pub mod call_peer_ready;
|
||||
pub mod call_peer_interrupted_streaming;
|
||||
pub mod res_check_password_token;
|
24
src/api_data/res_check_password_token.rs
Normal file
24
src/api_data/res_check_password_token.rs
Normal 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(),
|
||||
}
|
||||
}
|
||||
}
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user