mirror of
https://github.com/pierre42100/ComunicWeb
synced 2024-11-25 13:29:22 +00:00
Get the list of security questions of the user
This commit is contained in:
parent
bde2b5dde6
commit
fa1c1596d5
@ -1306,6 +1306,13 @@ var ComunicWeb = {
|
||||
//TODO : implement
|
||||
},
|
||||
|
||||
/**
|
||||
* Option : prompt security questions
|
||||
*/
|
||||
promptSecurityQuestions: {
|
||||
//TODO : implement
|
||||
},
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -60,6 +60,20 @@ ComunicWeb.components.account.interface = {
|
||||
ComunicWeb.common.api.makeAPIrequest(apiURI, params, true, callback);
|
||||
},
|
||||
|
||||
/**
|
||||
* Given an email address, returns the security questions of a user
|
||||
*
|
||||
* @param {String} email The email address of the account
|
||||
* @param {function} callback
|
||||
*/
|
||||
getSecurityQuestions: function(email, callback){
|
||||
var apiURI = "account/get_security_questions";
|
||||
var params = {
|
||||
email: email
|
||||
};
|
||||
ComunicWeb.common.api.makeAPIrequest(apiURI, params, true, callback);
|
||||
},
|
||||
|
||||
/**
|
||||
* Request the export of all the data of the user
|
||||
*
|
||||
|
@ -74,10 +74,16 @@ ComunicWeb.pages.passwordForgotten.main = {
|
||||
emptyElem(boxBody);
|
||||
|
||||
//Open appropriate page
|
||||
//Send an email
|
||||
if(option == "mail"){
|
||||
ComunicWeb.pages.passwordForgotten.mailAdmin.open(email, boxBody);
|
||||
}
|
||||
|
||||
//Prompt security questions
|
||||
else if(option == "security_questions"){
|
||||
ComunicWeb.pages.passwordForgotten.promptSecurityQuestions.open(email, boxBody);
|
||||
}
|
||||
|
||||
//Option not recognized
|
||||
else {
|
||||
boxBody.appendChild(ComunicWeb.common.messages.createCalloutElem(
|
||||
|
@ -75,6 +75,9 @@ ComunicWeb.pages.passwordForgotten.promptOption = {
|
||||
class: "btn btn-default",
|
||||
innerHTML: "<i class='fa fa-question'></i> Answer your security questions"
|
||||
});
|
||||
securityQuestions.addEventListener("click", function(){
|
||||
callback("security_questions");
|
||||
});
|
||||
}
|
||||
|
||||
//Add an option to contact admin (always)
|
||||
|
54
assets/js/pages/passwordForgotten/promptSecurityQuestions.js
Normal file
54
assets/js/pages/passwordForgotten/promptSecurityQuestions.js
Normal file
@ -0,0 +1,54 @@
|
||||
/**
|
||||
* Prompt user security questions
|
||||
*
|
||||
* Password reset page
|
||||
*
|
||||
* @author Pierre HUBERT
|
||||
*/
|
||||
|
||||
ComunicWeb.pages.passwordForgotten.promptSecurityQuestions = {
|
||||
|
||||
/**
|
||||
* Prompt user security questions
|
||||
*
|
||||
* @param {String} email The email of the user
|
||||
* @param {HTMLElement} target The target for the form
|
||||
*/
|
||||
open: function(email, target){
|
||||
|
||||
//Show loading message
|
||||
target.appendChild(ComunicWeb.common.messages.createCalloutElem(
|
||||
"Please wait",
|
||||
"Please wait, we are loading your security questions...",
|
||||
"info"));
|
||||
|
||||
//Perform a request on the API
|
||||
ComunicWeb.components.account.interface.getSecurityQuestions(email, function(callback){
|
||||
|
||||
//Empty target
|
||||
emptyElem(target);
|
||||
|
||||
//Check for errors
|
||||
if(callback.error){
|
||||
return target.appendChild(ComunicWeb.common.messages.createCalloutElem(
|
||||
"Error",
|
||||
"An error occurred while retrieving your security questions...",
|
||||
"danger"));
|
||||
}
|
||||
|
||||
//Apply the form
|
||||
ComunicWeb.pages.passwordForgotten.promptSecurityQuestions._display_form(email, callback.questions, target);
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* Display the security questions input form
|
||||
*
|
||||
* @param {String} email The email address of the user
|
||||
* @param {Array} questions The questions of the user
|
||||
* @param {HTMLElement} target The target for the form
|
||||
*/
|
||||
_display_form: function(email, questions, target){
|
||||
console.log(questions);
|
||||
},
|
||||
}
|
@ -418,6 +418,7 @@ class Dev {
|
||||
"js/pages/passwordForgotten/promptEmail.js",
|
||||
"js/pages/passwordForgotten/promptOption.js",
|
||||
"js/pages/passwordForgotten/mailAdmin.js",
|
||||
"js/pages/passwordForgotten/promptSecurityQuestions.js",
|
||||
|
||||
//Logout page
|
||||
"js/pages/logout.js",
|
||||
|
Loading…
Reference in New Issue
Block a user