mirror of
https://gitlab.com/comunic/comunicapiv3
synced 2024-11-26 07:19:22 +00:00
Can check if security questions has been defined
This commit is contained in:
parent
515f8d2ffc
commit
e76b3180e7
@ -43,4 +43,5 @@ pub mod res_count_all_unreads;
|
||||
pub mod notification_api;
|
||||
pub mod user_membership_api;
|
||||
mod type_container_api;
|
||||
pub mod res_check_email_exists;
|
||||
pub mod res_check_email_exists;
|
||||
pub mod res_check_security_questions_exists;
|
@ -4,7 +4,6 @@
|
||||
use serde::Serialize;
|
||||
|
||||
#[derive(Serialize)]
|
||||
#[allow(non_snake_case)]
|
||||
pub struct ResCheckEmailExists {
|
||||
exists: bool
|
||||
}
|
||||
|
15
src/api_data/res_check_security_questions_exists.rs
Normal file
15
src/api_data/res_check_security_questions_exists.rs
Normal file
@ -0,0 +1,15 @@
|
||||
//! # Check if security questions are set for a user
|
||||
//!
|
||||
//! @author Pierre Hubert
|
||||
use serde::Serialize;
|
||||
|
||||
#[derive(Serialize)]
|
||||
pub struct ResCheckSecurityQuestionsExists {
|
||||
defined: bool
|
||||
}
|
||||
|
||||
impl ResCheckSecurityQuestionsExists {
|
||||
pub fn new(defined: bool) -> ResCheckSecurityQuestionsExists {
|
||||
ResCheckSecurityQuestionsExists { defined }
|
||||
}
|
||||
}
|
@ -1,6 +1,7 @@
|
||||
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_security_questions_exists::ResCheckSecurityQuestionsExists;
|
||||
use crate::controllers::routes::RequestResult;
|
||||
use crate::data::error::ResultBoxError;
|
||||
use crate::data::http_request_handler::HttpRequestHandler;
|
||||
@ -79,7 +80,5 @@ pub fn exists_mail(r: &mut HttpRequestHandler) -> RequestResult {
|
||||
pub fn has_security_questions(r: &mut HttpRequestHandler) -> RequestResult {
|
||||
let user = r.post_user_info_from_email("email")?;
|
||||
|
||||
// TODO : continue implementation
|
||||
println!("{:#?}", user);
|
||||
r.success("implement me")
|
||||
r.set_response(ResCheckSecurityQuestionsExists::new(user.has_security_questions()))
|
||||
}
|
@ -68,6 +68,10 @@ pub struct User {
|
||||
pub block_comments_on_his_page: bool,
|
||||
pub allow_posts_from_friends: bool,
|
||||
pub account_creation_time: u64,
|
||||
pub security_question_1: Option<String>,
|
||||
pub security_answer_1: Option<String>,
|
||||
pub security_question_2: Option<String>,
|
||||
pub security_answer_2: Option<String>,
|
||||
}
|
||||
|
||||
impl User {
|
||||
@ -86,4 +90,12 @@ impl User {
|
||||
pub fn has_account_image(&self) -> bool {
|
||||
self.account_image_path.is_some()
|
||||
}
|
||||
|
||||
/// Check out whether security questions have been defined for this user or not
|
||||
pub fn has_security_questions(&self) -> bool {
|
||||
self.security_question_1.is_some() &&
|
||||
self.security_answer_1.is_some() &&
|
||||
self.security_question_2.is_some() &&
|
||||
self.security_answer_2.is_some()
|
||||
}
|
||||
}
|
@ -64,6 +64,10 @@ fn exec_get_user_query(query: database::QueryInfo) -> ResultBoxError<User> {
|
||||
block_comments_on_his_page: res.get_legacy_bool("bloquecommentaire")?,
|
||||
allow_posts_from_friends: res.get_legacy_bool("autoriser_post_amis")?,
|
||||
account_creation_time: res.get_date_as_time("date_creation")?,
|
||||
security_question_1: res.get_optional_str("question1")?,
|
||||
security_answer_1: res.get_optional_str("reponse1")?,
|
||||
security_question_2: res.get_optional_str("question2")?,
|
||||
security_answer_2: res.get_optional_str("reponse2")?,
|
||||
})
|
||||
})
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user