Skip to content
This repository has been archived by the owner on Jul 6, 2020. It is now read-only.

fix: Fix #123 Password Validation Error on Signup #124

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/app/components/auth/signup/signup.component.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<div class="signup-container">
<app-input [isRequired]="true" [label]="'Username'" [type]="'text'" [theme]="'dark'" [icon]="'assets/images/username_dark.png'" #formsignup></app-input>
<app-input [isRequired]="true" [label]="'Email'" [type]="'email'" [theme]="'dark'" [icon]="'assets/images/envelope_dark.png'" #formsignup></app-input>
<app-input [isRequired]="true" [label]="'Password'" [type]="'password'" [theme]="'dark'" [icon]="'assets/images/password_dark.png'" #formsignup></app-input>
<app-input [isRequired]="true" [label]="'Password1'" [type]="'password'" [theme]="'dark'" [icon]="'assets/images/password_dark.png'" #formsignup></app-input>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please elaborate a bit about these changes. Also let us know other scenarios like alphabet only, Capital letter, special character etc.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've checked other scenarios and it's breaking on entirely numeric password for me.

So, when the password is entirely numeric the server returns the error with the key "password1", now the problem is that there's a function called formValueForLabel whose job is to fetch the form field against the given key, since the submission has failed and we're in the error handling part, when given "password1" as the key the function fails to fetch the field since the label of the field is "password" and not "password1". That's why the error was not showing for entirely numeric password.

<app-input [isRequired]="true" [label]="'Confirm Password'" [type]="'password'" [theme]="'dark'" [icon]="'assets/images/confirm_dark.png'" #formsignup></app-input>
<div class="auth-btn-div">
<span class="btn btn-fire" (click)="formValidate('formsignup')">SIGN UP</span>
Expand Down
2 changes: 1 addition & 1 deletion src/app/components/auth/signup/signup.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ export class SignupComponent implements OnInit, AfterViewInit {
const SIGNUP_BODY = JSON.stringify({
username: self.globalService.formValueForLabel(self.ALL_FORMS[self.signupForm], 'username'),
email: self.globalService.formValueForLabel(self.ALL_FORMS[self.signupForm], 'email'),
password1: self.globalService.formValueForLabel(self.ALL_FORMS[self.signupForm], 'password'),
password1: self.globalService.formValueForLabel(self.ALL_FORMS[self.signupForm], 'password1'),
password2: self.globalService.formValueForLabel(self.ALL_FORMS[self.signupForm], 'confirm password')
});
self.apiService.postUrl(self.endpointsService.signupURL(), SIGNUP_BODY).subscribe(
Expand Down