Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix error rendering bug in 'Change Password' form #1743

Merged
merged 1 commit into from
Jan 2, 2022

Conversation

SakshiUppoor
Copy link
Contributor

@SakshiUppoor SakshiUppoor commented Jan 2, 2022

Fixes #1733

The error is not being displayed because the hidden condition is:

[hidden]="!(error && !passwordControl.dirty && !newPasswordControl.dirty && !repeatNewPasswordControl.dirty)">

This condition always remains true because passwordControl.dirty always remains true. This is due to the fact that whenever the server returns an error, then resetPasswords() is called, which only sets newPasswordControl and repeatNewPasswordControl to untouched & pristine and not passwordControl. Therefore, passwordControl always remains dirty.

}, (error) => {
console.log(error)
this.error = error
this.confirmation = undefined
this.resetPasswords()
})

To solve this issue, I shifted lines 62 and 63 to resetPasswords()

resetForm () {
this.passwordControl.setValue('')
this.passwordControl.markAsPristine()
this.passwordControl.markAsUntouched()
this.resetPasswords()
}
resetPasswords () {
this.newPasswordControl.setValue('')
this.newPasswordControl.markAsPristine()
this.newPasswordControl.markAsUntouched()
this.repeatNewPasswordControl.setValue('')
this.repeatNewPasswordControl.markAsPristine()
this.repeatNewPasswordControl.markAsUntouched()
}

Tested on:
OS: Windows 10
Browser: Google Chrome - Version 94.0.4606.81 (Official Build) (64-bit)

Signed-off-by: Sakshi Uppoor <sakshiuppoor@gmail.com>
@bkimminich
Copy link
Member

Wow, I totally overlooked that one... Great that you found it! CI is running now, will merge once it passes! 👍

@bkimminich bkimminich merged commit 09e6229 into juice-shop:develop Jan 2, 2022
@github-actions github-actions bot locked and limited conversation to collaborators Jan 3, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants