From e3e15f558453149523f3dbe6a9d1ff93df4df6a4 Mon Sep 17 00:00:00 2001 From: "venbatechnologies@gmail.com" Date: Sat, 29 Jan 2022 10:53:22 +0530 Subject: [PATCH] otp functionalities --- ng6-seed/src/app/app.module.ts | 5 +- .../src/app/dashboard/dashboard.service.ts | 18 +++++ .../pd-allocation.component.scss | 2 +- .../src/app/session/login/login.component.ts | 77 ++++++++++++++++++- .../src/app/session/otp/otp.component.html | 31 +++++++- .../src/app/session/otp/otp.component.scss | 18 +++++ ng6-seed/src/app/session/otp/otp.component.ts | 32 +++++++- ng6-seed/src/app/session/session.module.ts | 7 +- 8 files changed, 174 insertions(+), 16 deletions(-) diff --git a/ng6-seed/src/app/app.module.ts b/ng6-seed/src/app/app.module.ts index 655dae9cc..b3c2b757c 100755 --- a/ng6-seed/src/app/app.module.ts +++ b/ng6-seed/src/app/app.module.ts @@ -64,6 +64,7 @@ import { VideoChatComponent } from './video-chat/video-chat.component' import { PushNotifyService } from './shared/push-notify.service'; import { MatVideoModule } from 'mat-video'; import { ReqTokenInterceptor } from './_guard/req-token.interceptor'; +import { OtpComponent } from './session/otp/otp.component'; export function HttpLoaderFactory(http: HttpClient) { @@ -86,7 +87,7 @@ const DEFAULT_PERFECT_SCROLLBAR_CONFIG: PerfectScrollbarConfigInterface = { AdminLayoutComponent, AuthLayoutComponent, NewPasswordDialog,ForgotPass,ChangePasswordDialog, RoleMenuItemsPipe, HttpLoaderComponent, - IncomingCallComponent, VideoChatComponent, + IncomingCallComponent, VideoChatComponent,OtpComponent ], imports: [ MatDialogModule, @@ -150,7 +151,7 @@ const DEFAULT_PERFECT_SCROLLBAR_CONFIG: PerfectScrollbarConfigInterface = { }, MessagingService, AsyncPipe,LoaderService ], - entryComponents: [NewPasswordDialog,ForgotPass,ChangePasswordDialog,] + entryComponents: [NewPasswordDialog,ForgotPass,ChangePasswordDialog,OtpComponent] // IncomingCallComponent,VideoChatComponent,], ,bootstrap: [AppComponent] }) diff --git a/ng6-seed/src/app/dashboard/dashboard.service.ts b/ng6-seed/src/app/dashboard/dashboard.service.ts index 9c75cf2de..27eedc01d 100755 --- a/ng6-seed/src/app/dashboard/dashboard.service.ts +++ b/ng6-seed/src/app/dashboard/dashboard.service.ts @@ -117,5 +117,23 @@ private handleError(operation = 'operation', result?: T) { return of(result as T); }; } +// generateotp(email):Observable{ +// return this._http.post(this.apiUrl+'generateOTP', ''); +// } + +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/personal-discussion/manage-pd/list-pd/pd-allocation/pd-allocation.component.scss b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/pd-allocation/pd-allocation.component.scss index 044bbd96c..4286341fc 100755 --- a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/pd-allocation/pd-allocation.component.scss +++ b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/pd-allocation/pd-allocation.component.scss @@ -16,7 +16,7 @@ justify-content: center !important; } .paragraph_change { - color: #fff !important; + color: #fff !important; background-color: #e00201 !important; // padding: 10px !important; } diff --git a/ng6-seed/src/app/session/login/login.component.ts b/ng6-seed/src/app/session/login/login.component.ts index c12e25fe3..94cae5c53 100755 --- a/ng6-seed/src/app/session/login/login.component.ts +++ b/ng6-seed/src/app/session/login/login.component.ts @@ -15,6 +15,8 @@ import { MatDialog, MatDialogRef, MatDialogConfig } from '@angular/material'; import { CognitoService } from '../../AwsService/cognito.service'; import { MessagingService } from 'app/shared/messaging.service'; import { DashboardService } from 'app/dashboard/dashboard.service'; +import { OtpComponent } from '../otp/otp.component'; + @Component({ selector: 'ms-login-session', @@ -42,7 +44,8 @@ export class LoginComponent implements OnInit{ } }; commonDetails: any; - constructor( + dialogRef: MatDialogRef; + constructor( private router: Router, public aws: AwsService, public dialog: MatDialog, public shared:CognitoService,private messagingService:MessagingService,private dashBoardService:DashboardService) { @@ -116,11 +119,45 @@ export class LoginComponent implements OnInit{ 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 + { + + } + + }); + // let dialogRef = this.dialog.open(OtpComponent, this.config); + // dialogRef.afterClosed().subscribe(result => { + // if (result !== undefined) { + // let auth = { 'Username': this.email, 'Password': this.password, 'newpassword': result }; + // this.aws.dologin(auth).subscribe(res => { + // localStorage.setItem('user_role',res.idToken.payload["custom:role_id"]); + // this.getCommonSettings(); + // this.initializeNotification() + // this.router.navigate(['/home']); + // }, err => { + // alert(err.message); + // }) + // } + // }); + + - 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); @@ -223,4 +260,36 @@ export class ForgotPass { } +@Component({ + selector: 'app-jazz-dialog', + template: ` +
Forgot Password
+ + + + + + + + +
+ + + + + ` +}) +export class OTP { + + newpassword: any = newpassword; + confirmPassword: any = confirmPassword; + jazzMessage = 'Jazzy jazz jazz'; + + constructor(public dialogRef: MatDialogRef) { + + } + +} + + diff --git a/ng6-seed/src/app/session/otp/otp.component.html b/ng6-seed/src/app/session/otp/otp.component.html index 9b399b440..dbe4e390b 100644 --- a/ng6-seed/src/app/session/otp/otp.component.html +++ b/ng6-seed/src/app/session/otp/otp.component.html @@ -1,3 +1,28 @@ -

- otp works! -

+ +

+
+ OTP +
+
+ + +
+

+ + + + + + + + +
+ + +
+ +
diff --git a/ng6-seed/src/app/session/otp/otp.component.scss b/ng6-seed/src/app/session/otp/otp.component.scss index e69de29bb..e592fb882 100644 --- a/ng6-seed/src/app/session/otp/otp.component.scss +++ 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.ts b/ng6-seed/src/app/session/otp/otp.component.ts index 393a3115b..6f53e1896 100644 --- a/ng6-seed/src/app/session/otp/otp.component.ts +++ b/ng6-seed/src/app/session/otp/otp.component.ts @@ -1,15 +1,41 @@ -import { Component, OnInit } from '@angular/core'; - +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() { } + 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 0ad2c5dee..121d8d099 100755 --- a/ng6-seed/src/app/session/session.module.ts +++ b/ng6-seed/src/app/session/session.module.ts @@ -17,7 +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'; +//import { OtpComponent } from './otp/otp.component'; @NgModule({ imports: [ @@ -39,8 +39,9 @@ import { OtpComponent } from './otp/otp.component'; RegisterComponent, ForgotPasswordComponent, LockScreenComponent, - OtpComponent, - ] + //OtpComponent, + ], + // entryComponents:[OtpComponent] }) export class SessionModule {}