mirror of
				https://github.com/pierre42100/ComunicWeb
				synced 2025-11-04 04:04:20 +00:00 
			
		
		
		
	Get the list of security questions of the user
This commit is contained in:
		@@ -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);
 | 
			
		||||
	},
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user