mirror of
				https://github.com/pierre42100/ComunicWeb
				synced 2025-11-04 04:04:20 +00:00 
			
		
		
		
	Upgrade change password form
This commit is contained in:
		@@ -62,6 +62,14 @@ class PasswordInput {
 | 
				
			|||||||
        this._refreshArea();
 | 
					        this._refreshArea();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * @param {User} user 
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    setUser(user) {
 | 
				
			||||||
 | 
					        this._firstName = user.firstName;
 | 
				
			||||||
 | 
					        this._lastName = user.lastName;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    isValid() {
 | 
					    isValid() {
 | 
				
			||||||
        this._refreshArea();
 | 
					        this._refreshArea();
 | 
				
			||||||
        return this._valid;
 | 
					        return this._valid;
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -55,13 +55,16 @@ ComunicWeb.pages.settings.sections.password = {
 | 
				
			|||||||
			type: "password"
 | 
								type: "password"
 | 
				
			||||||
		});
 | 
							});
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		//Ask the user to enter its new password
 | 
							// Ask the user to enter its new password
 | 
				
			||||||
		var newPasswordInput = createFormGroup({
 | 
							var newPasswordInput = new PasswordInput(
 | 
				
			||||||
			target: formContener,
 | 
								formContener,
 | 
				
			||||||
			label: "New password",
 | 
								tr("New password"),
 | 
				
			||||||
			placeholder: "Your new password",
 | 
								tr("Your new password")
 | 
				
			||||||
			type: "password"
 | 
							);
 | 
				
			||||||
		});
 | 
							(async () => {
 | 
				
			||||||
 | 
								let user = await userInfo(userID());
 | 
				
			||||||
 | 
								newPasswordInput.setUser(user)
 | 
				
			||||||
 | 
							})();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		//Ask the user to confirm its new password
 | 
							//Ask the user to confirm its new password
 | 
				
			||||||
		var confirmNewPasswordInput = createFormGroup({
 | 
							var confirmNewPasswordInput = createFormGroup({
 | 
				
			||||||
@@ -84,18 +87,18 @@ ComunicWeb.pages.settings.sections.password = {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
			//Check the old and the new password
 | 
								//Check the old and the new password
 | 
				
			||||||
			if(!ComunicWeb.common.formChecker.checkInput(oldPasswordInput, true)){
 | 
								if(!ComunicWeb.common.formChecker.checkInput(oldPasswordInput, true)){
 | 
				
			||||||
				notify("Please specify your old password to update your password!", "danger");
 | 
									notify(tr("Please specify your old password to update your password!"), "danger");
 | 
				
			||||||
				return;
 | 
									return;
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			if(!ComunicWeb.common.formChecker.checkInput(newPasswordInput, true)){
 | 
								if(!newPasswordInput.isValid()){
 | 
				
			||||||
				notify("Please specify a new password to update your password!", "danger");
 | 
									notify(tr("Please specify a new password to update your password!"), "danger");
 | 
				
			||||||
				return;
 | 
									return;
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			//Check if the old and the new password are the same or not
 | 
								//Check if the old and the new password are the same or not
 | 
				
			||||||
			if(newPasswordInput.value !== confirmNewPasswordInput.value){
 | 
								if(newPasswordInput.value !== confirmNewPasswordInput.value){
 | 
				
			||||||
				notify("The new password and its confirmation are not the same!", "danger");
 | 
									notify(tr("The new password and its confirmation are not the same!"), "danger");
 | 
				
			||||||
				return;
 | 
									return;
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -109,12 +112,12 @@ ComunicWeb.pages.settings.sections.password = {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
				//Check for errors
 | 
									//Check for errors
 | 
				
			||||||
				if(result.error){
 | 
									if(result.error){
 | 
				
			||||||
					notify("An error occurred while trying to update user password!", "danger");
 | 
										notify(tr("An error occurred while trying to update user password!"), "danger");
 | 
				
			||||||
					return;
 | 
										return;
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
				//Success
 | 
									//Success
 | 
				
			||||||
				notify("Your password has been successfully updated !");
 | 
									notify(tr("Your password has been successfully updated !"));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
				//Refresh current page to remove passwords (security)
 | 
									//Refresh current page to remove passwords (security)
 | 
				
			||||||
				ComunicWeb.common.page.refresh_current_page();
 | 
									ComunicWeb.common.page.refresh_current_page();
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user