From 022740c53e8c0bb6debb95980f7793a0758282cf Mon Sep 17 00:00:00 2001 From: venbainfotech Date: Mon, 7 Feb 2022 18:13:03 +0530 Subject: [PATCH] forgot otp added --- ng6-seed/src/app/app.module.ts | 6 +-- .../src/app/dashboard/dashboard.service.ts | 14 +++++++ .../sales-pd-list/sales-pd.component.ts | 5 +-- .../src/app/session/login/login.component.ts | 27 ++++++++++++-- .../src/app/session/otp/otp.component.html | 28 ++++++++++++++ .../src/app/session/otp/otp.component.scss | 18 +++++++++ .../src/app/session/otp/otp.component.spec.ts | 25 +++++++++++++ ng6-seed/src/app/session/otp/otp.component.ts | 37 +++++++++++++++++++ ng6-seed/src/app/session/session.module.ts | 3 +- 9 files changed, 153 insertions(+), 10 deletions(-) create mode 100644 ng6-seed/src/app/session/otp/otp.component.html create mode 100644 ng6-seed/src/app/session/otp/otp.component.scss create mode 100644 ng6-seed/src/app/session/otp/otp.component.spec.ts create mode 100644 ng6-seed/src/app/session/otp/otp.component.ts diff --git a/ng6-seed/src/app/app.module.ts b/ng6-seed/src/app/app.module.ts index c44c619..3809af9 100755 --- a/ng6-seed/src/app/app.module.ts +++ b/ng6-seed/src/app/app.module.ts @@ -55,6 +55,7 @@ import { ReqTokenInterceptor } from './_guard/req-token.interceptor'; import { MatVideoModule } from 'mat-video'; import { MAT_DATE_LOCALE } from '@angular/material/core'; import { DialogOverviewExampleDialog } from './sales-pd/sales-pd-list/sales-pd.component'; +import { OtpComponent } from './session/otp/otp.component'; export function HttpLoaderFactory(http: HttpClient) { return new TranslateHttpLoader(http); } @@ -74,8 +75,7 @@ export function createTranslateLoader(http: HttpClient) { AuthLayoutComponent, NewPasswordDialog,ForgotPass,ChangePasswordDialog, RoleMenuItemsPipe, HttpLoaderComponent, - DialogOverviewExampleDialog - + DialogOverviewExampleDialog,OtpComponent ], imports: [ @@ -134,7 +134,7 @@ export function createTranslateLoader(http: HttpClient) { }, { provide:MAT_DATE_LOCALE, useValue: 'en-GB' } ], - entryComponents: [NewPasswordDialog,ForgotPass,ChangePasswordDialog], + entryComponents: [NewPasswordDialog,ForgotPass,ChangePasswordDialog,OtpComponent], bootstrap: [AppComponent] }) export class AppModule { } diff --git a/ng6-seed/src/app/dashboard/dashboard.service.ts b/ng6-seed/src/app/dashboard/dashboard.service.ts index 13a8d00..63a120e 100755 --- a/ng6-seed/src/app/dashboard/dashboard.service.ts +++ b/ng6-seed/src/app/dashboard/dashboard.service.ts @@ -24,5 +24,19 @@ export class DashboardService { getCommonSettingsConfig(){ return this._http.post(this.apiUrl+'getCommonConfig', ''); } + generateotp(email): Observable { + + return this._http.post(this.apiUrl + 'generateOTP', { "records":{ "email":email}}) + // .pipe( + // catchError(this.handleError('role', [])) + // ) + } + resetpassword(data,otp): Observable { + + return this._http.post(this.apiUrl + 'verifyOTP', { "records":{ "email":data,"OTP":otp}}) + // .pipe( + // catchError(this.handleError('role', [])) + // ) + } } \ No newline at end of file diff --git a/ng6-seed/src/app/sales-pd/sales-pd-list/sales-pd.component.ts b/ng6-seed/src/app/sales-pd/sales-pd-list/sales-pd.component.ts index 206fe48..f918826 100644 --- a/ng6-seed/src/app/sales-pd/sales-pd-list/sales-pd.component.ts +++ b/ng6-seed/src/app/sales-pd/sales-pd-list/sales-pd.component.ts @@ -53,8 +53,7 @@ export class SalesPdComponent implements OnInit { console.log(userDetails); let role= this.constantProvider.takeDecisionRouting(JSON.parse(userDetails)) - console.log(role) - + console.log(role) if(role == 'sales'){ this.is_sales_login = true this.getListofPD() @@ -63,7 +62,7 @@ export class SalesPdComponent implements OnInit { this.is_sales_login = false this.getListofPD() } - },2000) + },5000) setTimeout(()=>{ this.common = JSON.parse(localStorage.getItem('commonSettings')) diff --git a/ng6-seed/src/app/session/login/login.component.ts b/ng6-seed/src/app/session/login/login.component.ts index b90a820..a34d97c 100755 --- a/ng6-seed/src/app/session/login/login.component.ts +++ b/ng6-seed/src/app/session/login/login.component.ts @@ -15,6 +15,7 @@ import { MatDialog, MatDialogRef, MatDialogConfig } from '@angular/material'; import { CognitoService } from '../../AwsService/cognito.service'; import { DashboardService } from 'app/dashboard/dashboard.service'; import { LoaderService } from 'app/shared/loaderService/loader.service'; +import { OtpComponent } from '../otp/otp.component'; @Component({ selector: 'ms-login-session', @@ -42,6 +43,7 @@ export class LoginComponent implements OnInit{ } }; commonDetails: any; + dialogRef: MatDialogRef; constructor( private router: Router, public aws: AwsService, public dialog: MatDialog, public shared:CognitoService,private dashBoardService:DashboardService , private loaderService:LoaderService) { @@ -114,10 +116,29 @@ export class LoginComponent implements OnInit{ forgotpassword() { - let auth = { 'Username': this.email }; - this.aws.userforgotpass(auth).subscribe(res => { + this.dashBoardService.generateotp(this.email).subscribe( + data => { + console.log('data'); + console.log(data) + if (data.status == 200) { + this.dialogRef = this.dialog.open(OtpComponent, { + data: this.email, + width: '60%', + disableClose: true + }); + + } + // else + // { + + // } + + }); - }) + // let auth = { 'Username': this.email }; + // this.aws.userforgotpass(auth).subscribe(res => { + + // }) } loggedInCheck(){ //alert(this.shared.isLoggedIn); diff --git a/ng6-seed/src/app/session/otp/otp.component.html b/ng6-seed/src/app/session/otp/otp.component.html new file mode 100644 index 0000000..dbe4e39 --- /dev/null +++ b/ng6-seed/src/app/session/otp/otp.component.html @@ -0,0 +1,28 @@ + +

+
+ OTP +
+
+ + +
+

+ + + + + + + + +
+ + +
+ +
diff --git a/ng6-seed/src/app/session/otp/otp.component.scss b/ng6-seed/src/app/session/otp/otp.component.scss new file mode 100644 index 0000000..e592fb8 --- /dev/null +++ b/ng6-seed/src/app/session/otp/otp.component.scss @@ -0,0 +1,18 @@ +mat-form-field { + margin: 0 2%; + } +.paragraph_change { + color: #fff !important; + background-color: #e00201 !important; + // padding: 10px !important; +} + .cdk-global-overlay-wrapper{ + justify-content: center !important; +} + mat-dialog-actions{ + border-top: 2px solid #e00201; + } + +.mat-form-field-appearance-legacy .mat-hint{ + color:rgba(0, 0, 0, 0.8) !important; +} diff --git a/ng6-seed/src/app/session/otp/otp.component.spec.ts b/ng6-seed/src/app/session/otp/otp.component.spec.ts new file mode 100644 index 0000000..9f338d7 --- /dev/null +++ b/ng6-seed/src/app/session/otp/otp.component.spec.ts @@ -0,0 +1,25 @@ +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; + +import { OtpComponent } from './otp.component'; + +describe('OtpComponent', () => { + let component: OtpComponent; + let fixture: ComponentFixture; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [ OtpComponent ] + }) + .compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(OtpComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/ng6-seed/src/app/session/otp/otp.component.ts b/ng6-seed/src/app/session/otp/otp.component.ts new file mode 100644 index 0000000..6cb4543 --- /dev/null +++ b/ng6-seed/src/app/session/otp/otp.component.ts @@ -0,0 +1,37 @@ +import { Component, OnInit, Inject } from '@angular/core'; +import { MatDialogRef, MatDialog, MAT_DIALOG_DATA } from '@angular/material'; +import { DashboardService } from 'app/dashboard/dashboard.service'; + +@Component({ + selector: 'app-otp', + templateUrl: './otp.component.html', + styleUrls: ['./otp.component.scss'] +}) +export class OtpComponent implements OnInit { + + constructor(private dialogRef: MatDialogRef,private dialog: MatDialog, @Inject(MAT_DIALOG_DATA) public data: any,private dashBoardService:DashboardService) { } + + ngOnInit() { + } + updatepassword(otp) + { + console.log('data'); + console.log(this.data); + this.dashBoardService.resetpassword(this.data,otp).subscribe( + data => { + console.log('data'); + console.log(data) + if (data.status == 200) { + alert('Password Reset Successfully'); + this.dialogRef.close(); + } + else + { + alert('OTP is invalid. Plesae enter correct OTP.!'); + + } + + }) +} + +} diff --git a/ng6-seed/src/app/session/session.module.ts b/ng6-seed/src/app/session/session.module.ts index e5709cd..0125518 100755 --- a/ng6-seed/src/app/session/session.module.ts +++ b/ng6-seed/src/app/session/session.module.ts @@ -17,6 +17,7 @@ import { ForgotPasswordComponent } from './forgot-password/forgot-password.compo import { LockScreenComponent } from './lockscreen/lockscreen.component'; import { SessionRoutes } from './session.routing'; +import { OtpComponent } from './otp/otp.component'; @NgModule({ imports: [ @@ -37,7 +38,7 @@ import { SessionRoutes } from './session.routing'; LoginComponent, RegisterComponent, ForgotPasswordComponent, - LockScreenComponent, + LockScreenComponent ] })