-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
resolves abhi9720/BankingPortal-API#13 Add methods to reset pin and p…
…assword (#10) * implement ui for forget password * added validations for password * account password reset implemented and validation added to form for password
- Loading branch information
Showing
12 changed files
with
360 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
src/app/components/reset-password/reset-password.component.css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
:host { | ||
|
||
display: flex; | ||
flex: 1; | ||
} | ||
|
||
.coverparentspace { | ||
flex: 1; | ||
display: flex; | ||
flex-direction: column; | ||
} |
90 changes: 90 additions & 0 deletions
90
src/app/components/reset-password/reset-password.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
<div class="h-screen flex items-center justify-center bg-gray-100 coverparentspace"> | ||
<div class="max-w-md w-full"> | ||
<div *ngIf="!showNewPasswordForm"> | ||
<!-- Step 1: Enter Email or Account Number --> | ||
<div class="border-none md:border border-gray-300 px-4 py-3 mb-8 bg-white rounded-lg shadow-none md:shadow-md"> | ||
<h2 class="my-3 text-center text-3xl font-extrabold text-gray-900">Reset Password</h2> | ||
<form [formGroup]="resetPasswordForm" (ngSubmit)="sendOtp()"> | ||
<!-- Display OTP input if OTP is sent successfully --> | ||
<ng-container *ngIf="!otpSentSuccessfully; else otpInputSection"> | ||
<div class="mb-4"> | ||
<label for="identifier" class="block text-sm font-bold mb-2">Email or Account Number:</label> | ||
<input formControlName="identifier" type="text" id="identifier" | ||
class="w-full px-3 py-2 border rounded-lg shadow-sm focus:outline-none focus:border-indigo-500" /> | ||
<div *ngIf="resetPasswordForm.get('identifier')?.invalid && resetPasswordForm.get('identifier')?.touched" | ||
class="text-red-500 text-sm mt-1"> | ||
Email or Account Number is required. | ||
</div> | ||
</div> | ||
<div class="flex items-center justify-between"> | ||
<button type="submit" [disabled]="resetPasswordForm.invalid" | ||
class="group relative w-full flex justify-center py-2 px-4 bg-indigo-500 hover:bg-indigo-700 text-white font-bold py-3 px-6 rounded focus:outline-none focus:shadow-outline disabled:opacity-50 disabled:cursor-not-allowed">Send OTP</button> | ||
</div> | ||
</ng-container> | ||
|
||
<!-- OTP input section --> | ||
<ng-template #otpInputSection> | ||
<div class="mb-4"> | ||
<label for="otp" class="block text-sm font-bold mb-2">Enter OTP:</label> | ||
<ng-otp-input #ngOtpInput (onInputChange)="onOtpChange($event)" [config]="config"></ng-otp-input> | ||
<input formControlName="otp" type="hidden" id="otp" [value]="resetPasswordForm.get('otp')?.value"> | ||
</div> | ||
<div class="flex items-center justify-between"> | ||
<button type="button" (click)="verifyOtp()" | ||
class="group relative w-full flex justify-center py-2 px-4 bg-indigo-500 hover:bg-indigo-700 text-white font-bold py-3 px-6 rounded focus:outline-none focus:shadow-outline disabled:opacity-50 disabled:cursor-not-allowed">Verify OTP</button> | ||
</div> | ||
</ng-template> | ||
</form> | ||
<a class="block mt-4 font-semibold leading-6 text-indigo-600 hover:text-indigo-500" routerLink="/login">Back to Login</a> | ||
</div> | ||
</div> | ||
|
||
<div *ngIf="showNewPasswordForm"> | ||
<!-- Step 3: Enter New Password --> | ||
<div class="border-none md:border border-gray-300 px-4 py-3 mb-8 bg-white rounded-lg shadow-none md:shadow-md"> | ||
<h2 class="my-3 text-center text-3xl font-extrabold text-gray-900">Reset Password</h2> | ||
<form [formGroup]="newPasswordForm" (ngSubmit)="resetPassword()"> | ||
<div class="mb-4"> | ||
<label for="newPassword" class="block text-sm font-bold mb-2">New Password:</label> | ||
<input formControlName="newPassword" type="password" id="newPassword" | ||
class="w-full px-3 py-2 border rounded-lg shadow-sm focus:outline-none focus:border-indigo-500" /> | ||
<!-- <div *ngIf="newPasswordForm.get('newPassword')?.invalid && newPasswordForm.get('newPassword')?.touched" | ||
class="text-red-500 text-sm mt-1"> | ||
New Password is required. | ||
</div> --> | ||
</div> | ||
<div class="mb-4"> | ||
<label for="confirmPassword" class="block text-sm font-bold mb-2">Confirm Password:</label> | ||
<input formControlName="confirmPassword" type="password" id="confirmPassword" | ||
class="w-full px-3 py-2 border rounded-lg shadow-sm focus:outline-none focus:border-indigo-500" /> | ||
|
||
<div *ngIf="newPasswordForm.get('confirmPassword')?.invalid && newPasswordForm.get('confirmPassword')?.touched" | ||
class="text-red-500 text-sm mt-1"> | ||
Confirm Password is required and must match the New Password. | ||
</div> | ||
|
||
<div | ||
*ngIf="f.newPassword.invalid && f.newPassword.touched" | ||
class="text-red-500 text-sm mt-1" | ||
> | ||
<div *ngIf="f.newPassword.errors?.required"> | ||
Password is required. | ||
</div> | ||
<div *ngIf="f.newPassword.errors?.minlength"> | ||
Password must be at least 8 characters long. | ||
</div> | ||
<div *ngIf="f.newPassword.errors?.maxlength"> | ||
Password must be at most 127 characters long. | ||
</div> | ||
</div> | ||
|
||
</div> | ||
<div class="flex items-center justify-between"> | ||
<button type="submit" [disabled]="newPasswordForm.invalid" | ||
class="group relative w-full flex justify-center py-2 px-4 bg-indigo-500 hover:bg-indigo-700 text-white font-bold py-3 px-6 rounded focus:outline-none focus:shadow-outline disabled:opacity-50 disabled:cursor-not-allowed">Reset Password</button> | ||
</div> | ||
</form> | ||
</div> | ||
</div> | ||
</div> | ||
</div> |
23 changes: 23 additions & 0 deletions
23
src/app/components/reset-password/reset-password.component.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { ComponentFixture, TestBed } from '@angular/core/testing'; | ||
|
||
import { ResetPasswordComponent } from './reset-password.component'; | ||
|
||
describe('ResetPasswordComponent', () => { | ||
let component: ResetPasswordComponent; | ||
let fixture: ComponentFixture<ResetPasswordComponent>; | ||
|
||
beforeEach(async () => { | ||
await TestBed.configureTestingModule({ | ||
imports: [ResetPasswordComponent] | ||
}) | ||
.compileComponents(); | ||
|
||
fixture = TestBed.createComponent(ResetPasswordComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
Oops, something went wrong.