From eed8d4a2398109f18e15161b224060a9323fd41b Mon Sep 17 00:00:00 2001 From: kj1352 Date: Tue, 1 Dec 2020 13:33:10 +0530 Subject: [PATCH] Frogot password UI and API connection to get OTP --- src/app/app-routing.module.ts | 5 +-- .../forgot-password/forgot-password.module.ts | 26 ++++++++++++++++ .../forgot-password/forgot-password.page.html | 18 +++++++++++ .../forgot-password/forgot-password.page.scss | 1 + .../forgot-password.page.spec.ts | 27 ++++++++++++++++ .../forgot-password/forgot-password.page.ts | 31 +++++++++++++++++++ src/app/login/login.page.html | 2 +- src/app/services/auth.service.ts | 4 +++ src/global.scss | 1 + 9 files changed, 112 insertions(+), 3 deletions(-) create mode 100644 src/app/forgot-password/forgot-password.module.ts create mode 100644 src/app/forgot-password/forgot-password.page.html create mode 100644 src/app/forgot-password/forgot-password.page.scss create mode 100644 src/app/forgot-password/forgot-password.page.spec.ts create mode 100644 src/app/forgot-password/forgot-password.page.ts diff --git a/src/app/app-routing.module.ts b/src/app/app-routing.module.ts index 39f1a8b..4b9ebcc 100644 --- a/src/app/app-routing.module.ts +++ b/src/app/app-routing.module.ts @@ -5,14 +5,15 @@ const routes: Routes = [ { path: '', redirectTo: 'login', pathMatch: 'full' }, { path: 'onboarding', loadChildren: './onboarding/onboarding.module#OnboardingPageModule' }, { path: 'login', loadChildren: './login/login.module#LoginPageModule' }, + { path: 'forgot-password', loadChildren: './forgot-password/forgot-password.module#ForgotPasswordPageModule' }, { path: 'malls', loadChildren: './malls/malls.module#MallsPageModule' }, { path: 'mall-details', loadChildren: './mall-details/mall-details.module#MallDetailsPageModule' }, { path: 'outlet-details', loadChildren: './outlet-details/outlet-details.module#OutletDetailsPageModule' }, { path: 'cart', loadChildren: './cart/cart.module#CartPageModule' }, { path: 'profile', loadChildren: './profile/profile.module#ProfilePageModule' }, { path: 'bookmark', loadChildren: './bookmark/bookmark.module#BookmarkPageModule' }, - { path: 'near', loadChildren: './near/near.module#NearPageModule' }, { path: 'in-app-browser', loadChildren: './in-app-browser/in-app-browser.module#InAppBrowserPageModule' }, - + { path: 'near', loadChildren: './near/near.module#NearPageModule' }, + { path: 'in-app-browser', loadChildren: './in-app-browser/in-app-browser.module#InAppBrowserPageModule' }, ]; @NgModule({ diff --git a/src/app/forgot-password/forgot-password.module.ts b/src/app/forgot-password/forgot-password.module.ts new file mode 100644 index 0000000..be2088e --- /dev/null +++ b/src/app/forgot-password/forgot-password.module.ts @@ -0,0 +1,26 @@ +import { NgModule } from '@angular/core'; +import { CommonModule } from '@angular/common'; +import { FormsModule } from '@angular/forms'; +import { Routes, RouterModule } from '@angular/router'; + +import { IonicModule } from '@ionic/angular'; + +import { ForgotPasswordPage } from './forgot-password.page'; + +const routes: Routes = [ + { + path: '', + component: ForgotPasswordPage + } +]; + +@NgModule({ + imports: [ + CommonModule, + FormsModule, + IonicModule, + RouterModule.forChild(routes) + ], + declarations: [ForgotPasswordPage] +}) +export class ForgotPasswordPageModule {} diff --git a/src/app/forgot-password/forgot-password.page.html b/src/app/forgot-password/forgot-password.page.html new file mode 100644 index 0000000..7eb0fda --- /dev/null +++ b/src/app/forgot-password/forgot-password.page.html @@ -0,0 +1,18 @@ + + + diff --git a/src/app/forgot-password/forgot-password.page.scss b/src/app/forgot-password/forgot-password.page.scss new file mode 100644 index 0000000..12a5a74 --- /dev/null +++ b/src/app/forgot-password/forgot-password.page.scss @@ -0,0 +1 @@ +@import '../login/login.page.scss'; \ No newline at end of file diff --git a/src/app/forgot-password/forgot-password.page.spec.ts b/src/app/forgot-password/forgot-password.page.spec.ts new file mode 100644 index 0000000..da58246 --- /dev/null +++ b/src/app/forgot-password/forgot-password.page.spec.ts @@ -0,0 +1,27 @@ +import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core'; +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; + +import { ForgotPasswordPage } from './forgot-password.page'; + +describe('ForgotPasswordPage', () => { + let component: ForgotPasswordPage; + let fixture: ComponentFixture; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [ ForgotPasswordPage ], + schemas: [CUSTOM_ELEMENTS_SCHEMA], + }) + .compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(ForgotPasswordPage); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/forgot-password/forgot-password.page.ts b/src/app/forgot-password/forgot-password.page.ts new file mode 100644 index 0000000..9709e3a --- /dev/null +++ b/src/app/forgot-password/forgot-password.page.ts @@ -0,0 +1,31 @@ +import { Component, OnInit } from '@angular/core'; +import { AuthService } from '../services/auth.service'; +import { ToastService } from '../services/toast.service'; + +@Component({ + selector: 'app-forgot-password', + templateUrl: './forgot-password.page.html', + styleUrls: ['./forgot-password.page.scss'], +}) +export class ForgotPasswordPage implements OnInit { + email: string = ''; + + constructor( + private authService: AuthService, + private toastService: ToastService + ) { } + + ngOnInit() { + } + + getOtp() { + this.authService.forgotPassword(this.email).then((data) => { + console.log(data); + this.toastService.presentToast("OTP Sent to your Email ID", "success"); + }, (err) => { + console.log(err); + this.toastService.presentToast("Failed to send OTP, Please check your credentials", "danger"); + }); + } + +} diff --git a/src/app/login/login.page.html b/src/app/login/login.page.html index 23eaef6..6f8ea16 100644 --- a/src/app/login/login.page.html +++ b/src/app/login/login.page.html @@ -21,7 +21,7 @@ - Forgot Password? + Forgot Password? diff --git a/src/app/services/auth.service.ts b/src/app/services/auth.service.ts index 7020889..c6d328e 100644 --- a/src/app/services/auth.service.ts +++ b/src/app/services/auth.service.ts @@ -15,6 +15,10 @@ export class AuthService { return this.http.post(URL + '/api/auth/signin/', credentials).toPromise(); } + forgotPassword(email: string) { + return this.http.post(URL + '/api/auth/forgot/', { email: email }).toPromise(); + } + requestMailOTP(email: string) { return this.http.post(URL + '/api/otp/generate/', { email: email }).toPromise(); } diff --git a/src/global.scss b/src/global.scss index 9bb7ba5..25130f4 100644 --- a/src/global.scss +++ b/src/global.scss @@ -32,6 +32,7 @@ p { text-transform: none; outline: none; font-weight: 500; + text-decoration: none; } h1, h2,