From 2971b7efbed82329f0a21a986a74eb7776c84e24 Mon Sep 17 00:00:00 2001 From: "venbatechnologies@gmail.com" Date: Thu, 3 Feb 2022 18:31:37 +0530 Subject: [PATCH] otp changes --- ng6-seed/src/app/app.module.ts | 5 ++- .../src/app/dashboard/dashboard.service.ts | 10 +++++ .../src/app/session/login/login.component.ts | 33 ++++++++++++--- .../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 | 41 +++++++++++++++++++ ng6-seed/src/app/session/session.module.ts | 2 + 8 files changed, 156 insertions(+), 6 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 5fbd760..0bfe0de 100755 --- a/ng6-seed/src/app/app.module.ts +++ b/ng6-seed/src/app/app.module.ts @@ -54,9 +54,11 @@ import { environment } from '../environments/environment'; import { ReqTokenInterceptor } from './_guard/req-token.interceptor'; import { MatVideoModule } from 'mat-video'; import { MAT_DATE_LOCALE } from '@angular/material/core'; + //import { AdvanceFilterComponent } from './sales-pd/sales-pd-list/advance-filter/advance-filter.component'; //import { DialogOverviewExampleDialog } from './sales-pd/sales-pd-list/sales-pd.component'; 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); } @@ -76,6 +78,7 @@ export function createTranslateLoader(http: HttpClient) { AuthLayoutComponent, NewPasswordDialog,ForgotPass,ChangePasswordDialog, RoleMenuItemsPipe, HttpLoaderComponent, + OtpComponent, // AdvanceFilterComponent, DialogOverviewExampleDialog ], @@ -134,7 +137,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..5992727 100755 --- a/ng6-seed/src/app/dashboard/dashboard.service.ts +++ b/ng6-seed/src/app/dashboard/dashboard.service.ts @@ -24,5 +24,15 @@ export class DashboardService { getCommonSettingsConfig(){ return this._http.post(this.apiUrl+'getCommonConfig', ''); } + generateotp(email): Observable { + + return this._http.post(this.apiUrl + 'generateOTP', { "records":{ "email":email}}) + + } + resetpassword(data,otp): Observable { + + return this._http.post(this.apiUrl + 'verifyOTP', { "records":{ "email":data,"OTP":otp}}) + + } } \ No newline at end of file diff --git a/ng6-seed/src/app/session/login/login.component.ts b/ng6-seed/src/app/session/login/login.component.ts index 390c677..f2e34a7 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) { @@ -99,6 +101,27 @@ export class LoginComponent implements OnInit{ this.loaderService.closeMatSpinnerDialog(); //alert(err.message); }) + } + forgotpassword() { + 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 + { + + } + + }); + } /** * New password set @@ -125,13 +148,13 @@ export class LoginComponent implements OnInit{ } - forgotpassword() { + // forgotpassword() { - let auth = { 'Username': this.email }; - this.aws.userforgotpass(auth).subscribe(res => { + // let auth = { 'Username': this.email }; + // this.aws.userforgotpass(auth).subscribe(res => { - }) - } + // }) + // } loggedInCheck(){ //alert(this.shared.isLoggedIn); if(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..6f53e18 --- /dev/null +++ b/ng6-seed/src/app/session/otp/otp.component.ts @@ -0,0 +1,41 @@ +import { Component, OnInit,Inject } from '@angular/core'; +import { MatDialog, MatDialogRef, MAT_DIALOG_DATA , DialogPosition} from '@angular/material'; +import { DashboardService } from 'app/dashboard/dashboard.service'; +import { NotifierService } from 'angular-notifier'; +@Component({ + selector: 'app-otp', + templateUrl: './otp.component.html', + styleUrls: ['./otp.component.scss'] +}) +export class OtpComponent implements OnInit { + //public notifier : NotifierService; + + 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..0806eb1 100755 --- a/ng6-seed/src/app/session/session.module.ts +++ b/ng6-seed/src/app/session/session.module.ts @@ -18,6 +18,7 @@ import { LockScreenComponent } from './lockscreen/lockscreen.component'; import { SessionRoutes } from './session.routing'; + @NgModule({ imports: [ CommonModule, @@ -38,6 +39,7 @@ import { SessionRoutes } from './session.routing'; RegisterComponent, ForgotPasswordComponent, LockScreenComponent, + ] })