mirror of
				https://github.com/pierre42100/ComunicWeb
				synced 2025-11-03 19:54:14 +00:00 
			
		
		
		
	Prompt user email on password reset
This commit is contained in:
		@@ -1285,6 +1285,13 @@ var ComunicWeb = {
 | 
				
			|||||||
				//TODO : implement
 | 
									//TODO : implement
 | 
				
			||||||
			},
 | 
								},
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								/**
 | 
				
			||||||
 | 
								 * Ask user email step
 | 
				
			||||||
 | 
								 */
 | 
				
			||||||
 | 
								promptEmail: {
 | 
				
			||||||
 | 
									//TODO : implement
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		/**
 | 
							/**
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -31,6 +31,20 @@ ComunicWeb.components.account.interface = {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	},
 | 
						},
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						/**
 | 
				
			||||||
 | 
						 * Check whether an email address is linked to an account or not
 | 
				
			||||||
 | 
						 * 
 | 
				
			||||||
 | 
						 * @param {String} email The email address to check
 | 
				
			||||||
 | 
						 * @param {function} callback
 | 
				
			||||||
 | 
						 */
 | 
				
			||||||
 | 
						existsMail: function(email, callback){
 | 
				
			||||||
 | 
							var apiURI = "account/exists_email";
 | 
				
			||||||
 | 
							var params = {
 | 
				
			||||||
 | 
								email: email
 | 
				
			||||||
 | 
							};
 | 
				
			||||||
 | 
							ComunicWeb.common.api.makeAPIrequest(apiURI, params, true, callback);
 | 
				
			||||||
 | 
						},
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/**
 | 
						/**
 | 
				
			||||||
	 * Request the export of all the data of the user
 | 
						 * Request the export of all the data of the user
 | 
				
			||||||
	 * 
 | 
						 * 
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -60,6 +60,11 @@ ComunicWeb.pages.passwordForgotten.main = {
 | 
				
			|||||||
			type: "div",
 | 
								type: "div",
 | 
				
			||||||
			class: "box-body"
 | 
								class: "box-body"
 | 
				
			||||||
		});
 | 
							});
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							//Perform first step: ask user his email
 | 
				
			||||||
 | 
							ComunicWeb.pages.passwordForgotten.promptEmail.open(boxBody, function(email){
 | 
				
			||||||
 | 
								alert("Email: " + email);
 | 
				
			||||||
 | 
							});
 | 
				
			||||||
	},
 | 
						},
 | 
				
			||||||
 | 
					
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
							
								
								
									
										95
									
								
								assets/js/pages/passwordForgotten/promptEmail.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										95
									
								
								assets/js/pages/passwordForgotten/promptEmail.js
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,95 @@
 | 
				
			|||||||
 | 
					/**
 | 
				
			||||||
 | 
					 * Prompt user email step
 | 
				
			||||||
 | 
					 * 
 | 
				
			||||||
 | 
					 * @author Pierre HUBERT
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					ComunicWeb.pages.passwordForgotten.promptEmail = {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						/**
 | 
				
			||||||
 | 
						 * Prompt user email
 | 
				
			||||||
 | 
						 * 
 | 
				
			||||||
 | 
						 * @param {HTMLElement} target The target for the form
 | 
				
			||||||
 | 
						 * @param {Function} callback Function to call once the user has entered
 | 
				
			||||||
 | 
						 * his email
 | 
				
			||||||
 | 
						 */
 | 
				
			||||||
 | 
						open: function(target, callback){
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							//Create the form
 | 
				
			||||||
 | 
							var form = createElem2({
 | 
				
			||||||
 | 
								appendTo: target,
 | 
				
			||||||
 | 
								type: "form"
 | 
				
			||||||
 | 
							});
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							//Add message target
 | 
				
			||||||
 | 
							var messageTarget = createElem2({
 | 
				
			||||||
 | 
								appendTo: form,
 | 
				
			||||||
 | 
								type: "div"
 | 
				
			||||||
 | 
							});
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							//Add field
 | 
				
			||||||
 | 
							var input = createFormGroup({
 | 
				
			||||||
 | 
								target: form,
 | 
				
			||||||
 | 
								label: "Your email address",
 | 
				
			||||||
 | 
								name: "email",
 | 
				
			||||||
 | 
								placeholder: "Email address",
 | 
				
			||||||
 | 
								type: "email"
 | 
				
			||||||
 | 
							});
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							//Add submit button
 | 
				
			||||||
 | 
							var submit = createElem2({
 | 
				
			||||||
 | 
								appendTo: form,
 | 
				
			||||||
 | 
								type: "input",
 | 
				
			||||||
 | 
								class: "btn btn-primary",
 | 
				
			||||||
 | 
								elemType: "submit",
 | 
				
			||||||
 | 
								value: "Submit"
 | 
				
			||||||
 | 
							});
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							//Create submit function
 | 
				
			||||||
 | 
							var lock = false;
 | 
				
			||||||
 | 
							var submit_form = function(){
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								//Check if the function is locked
 | 
				
			||||||
 | 
								if(lock)
 | 
				
			||||||
 | 
									return;
 | 
				
			||||||
 | 
								
 | 
				
			||||||
 | 
								//Empty messages target
 | 
				
			||||||
 | 
								emptyElem(messageTarget);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								//Check given email
 | 
				
			||||||
 | 
								if(!ComunicWeb.common.formChecker.checkInput(input, true))
 | 
				
			||||||
 | 
									return notify("Please specify a valid email address !", "danger");
 | 
				
			||||||
 | 
								
 | 
				
			||||||
 | 
								//Lock submit button
 | 
				
			||||||
 | 
								lock = true;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								//Get the email
 | 
				
			||||||
 | 
								var email = input.value;
 | 
				
			||||||
 | 
								
 | 
				
			||||||
 | 
								//Check whether the email is linked to an account or not
 | 
				
			||||||
 | 
								ComunicWeb.components.account.interface.existsMail(input.value, function(result){
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
									//Unlock the form
 | 
				
			||||||
 | 
									lock = false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
									//Check if the email is valid
 | 
				
			||||||
 | 
									if(!result.exists){
 | 
				
			||||||
 | 
										messageTarget.appendChild(ComunicWeb.common.messages.createCalloutElem("Error", "Specified email address not found !", "danger"));
 | 
				
			||||||
 | 
										return;
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
									//Else the email  exists
 | 
				
			||||||
 | 
									emptyElem(form);
 | 
				
			||||||
 | 
									form.remove();
 | 
				
			||||||
 | 
									callback(email);
 | 
				
			||||||
 | 
								});
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							//Catch form submission
 | 
				
			||||||
 | 
							form.onsubmit = function(){
 | 
				
			||||||
 | 
								submit_form();
 | 
				
			||||||
 | 
								return false;
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						},
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -413,6 +413,7 @@ class Dev {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
			//Password forgotten page
 | 
								//Password forgotten page
 | 
				
			||||||
			"js/pages/passwordForgotten/main.js",
 | 
								"js/pages/passwordForgotten/main.js",
 | 
				
			||||||
 | 
								"js/pages/passwordForgotten/promptEmail.js",
 | 
				
			||||||
			
 | 
								
 | 
				
			||||||
			//Logout page
 | 
								//Logout page
 | 
				
			||||||
			"js/pages/logout.js",
 | 
								"js/pages/logout.js",
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user