mirror of
https://github.com/pierre42100/ComunicWeb
synced 2024-11-26 05:49:22 +00:00
Prompt user preferred option to reset its password
This commit is contained in:
parent
79da14e0bc
commit
9a7c3245c4
14
assets/css/pages/passwordForgotten/promptOption.css
Normal file
14
assets/css/pages/passwordForgotten/promptOption.css
Normal file
@ -0,0 +1,14 @@
|
||||
/**
|
||||
* Password forgotten prompt option section stylesheet
|
||||
*
|
||||
* @author Pierre HUBERT
|
||||
*/
|
||||
|
||||
.password-reset-prompt-option-section p {
|
||||
text-align: justify;
|
||||
}
|
||||
|
||||
.password-reset-prompt-option-section .btn {
|
||||
width: 100%;
|
||||
margin-top: 10px;
|
||||
}
|
@ -1290,7 +1290,14 @@ var ComunicWeb = {
|
||||
*/
|
||||
promptEmail: {
|
||||
//TODO : implement
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Ask user reset option
|
||||
*/
|
||||
promptOption: {
|
||||
//TODO : implement
|
||||
},
|
||||
|
||||
},
|
||||
|
||||
|
@ -45,6 +45,21 @@ ComunicWeb.components.account.interface = {
|
||||
ComunicWeb.common.api.makeAPIrequest(apiURI, params, true, callback);
|
||||
},
|
||||
|
||||
/**
|
||||
* Check whether the security questions have been set for an account
|
||||
* with an email address or not
|
||||
*
|
||||
* @param {String} email The email address of the account
|
||||
* @param {function} callback
|
||||
*/
|
||||
checkSecurityQuestionsExistence: function(email, callback){
|
||||
var apiURI = "account/has_security_questions";
|
||||
var params = {
|
||||
email: email
|
||||
};
|
||||
ComunicWeb.common.api.makeAPIrequest(apiURI, params, true, callback);
|
||||
},
|
||||
|
||||
/**
|
||||
* Request the export of all the data of the user
|
||||
*
|
||||
|
@ -63,7 +63,16 @@ ComunicWeb.pages.passwordForgotten.main = {
|
||||
|
||||
//Perform first step: ask user his email
|
||||
ComunicWeb.pages.passwordForgotten.promptEmail.open(boxBody, function(email){
|
||||
alert("Email: " + email);
|
||||
|
||||
//Empty body
|
||||
emptyElem(boxBody);
|
||||
|
||||
//Prompt user reset option
|
||||
ComunicWeb.pages.passwordForgotten.promptOption.open(email, boxBody, function(option){
|
||||
|
||||
alert(option);
|
||||
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
|
89
assets/js/pages/passwordForgotten/promptOption.js
Normal file
89
assets/js/pages/passwordForgotten/promptOption.js
Normal file
@ -0,0 +1,89 @@
|
||||
/**
|
||||
* Prompt user option to reset his password page
|
||||
*
|
||||
* @author Pierre HUBERT
|
||||
*/
|
||||
|
||||
ComunicWeb.pages.passwordForgotten.promptOption = {
|
||||
|
||||
/**
|
||||
* Open prompt option page
|
||||
*
|
||||
* @param {String} email Target email address
|
||||
* @param {HTMLElement} target The target of the parameter
|
||||
* @param {Function} callback
|
||||
*/
|
||||
open: function(email, target, callback){
|
||||
|
||||
//Display loading message
|
||||
createElem2({
|
||||
appendTo: target,
|
||||
type: "p",
|
||||
innerHTML: "Please wait, we are checking available options..."
|
||||
});
|
||||
|
||||
//Check if security questions have been set on this account
|
||||
ComunicWeb.components.account.interface.checkSecurityQuestionsExistence(email, function(result){
|
||||
|
||||
emptyElem(target);
|
||||
|
||||
//Check for errors
|
||||
if(result.error){
|
||||
target.appendChild(ComunicWeb.common.messages.createCalloutElem(
|
||||
"An error occurred.",
|
||||
"An error occurred while retrieving available options. Please try to refresh the page and start again.",
|
||||
"danger"));
|
||||
return;
|
||||
}
|
||||
|
||||
//Display available options to the user
|
||||
ComunicWeb.pages.passwordForgotten.promptOption._show_options(result.defined, target, callback);
|
||||
});
|
||||
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* Display options to the user
|
||||
*
|
||||
* @param {Boolean} hasSecurityQuestions Specify wether the user can use security
|
||||
* questions to reset his password or not
|
||||
* @param {HTMLElement} target The target of the form
|
||||
* @param {Function} callback
|
||||
*/
|
||||
_show_options(hasSecurityQuestions, target, callback){
|
||||
|
||||
//Create a form
|
||||
var form = createElem2({
|
||||
type: "div",
|
||||
class: "password-reset-prompt-option-section",
|
||||
appendTo: target
|
||||
});
|
||||
|
||||
//Message
|
||||
createElem2({
|
||||
appendTo: form,
|
||||
type: "p",
|
||||
innerHTML: "Here are your available options to reset your password:"
|
||||
});
|
||||
|
||||
if(hasSecurityQuestions){
|
||||
//Add an option to answer security questions (if available)
|
||||
var securityQuestions = createElem2({
|
||||
appendTo: form,
|
||||
type: "div",
|
||||
class: "btn btn-default",
|
||||
innerHTML: "<i class='fa fa-question'></i> Answer your security questions"
|
||||
});
|
||||
}
|
||||
|
||||
//Add an option to contact admin (always)
|
||||
var contact = createElem2({
|
||||
appendTo: form,
|
||||
type: "div",
|
||||
class: "btn btn-default",
|
||||
innerHTML: "<i class='fa fa-envelope-o'></i> Contact the administration"
|
||||
});
|
||||
},
|
||||
|
||||
}
|
@ -227,7 +227,8 @@ class Dev {
|
||||
"css/pages/createAccount.css",
|
||||
|
||||
//Password forgotten page
|
||||
"css/pages/passwordForgotten/main.css"
|
||||
"css/pages/passwordForgotten/main.css",
|
||||
"css/pages/passwordForgotten/promptOption.css"
|
||||
);
|
||||
|
||||
/**
|
||||
@ -414,6 +415,7 @@ class Dev {
|
||||
//Password forgotten page
|
||||
"js/pages/passwordForgotten/main.js",
|
||||
"js/pages/passwordForgotten/promptEmail.js",
|
||||
"js/pages/passwordForgotten/promptOption.js",
|
||||
|
||||
//Logout page
|
||||
"js/pages/logout.js",
|
||||
|
Loading…
Reference in New Issue
Block a user