otp functionalities

This commit is contained in:
venbatechnologies@gmail.com 2022-01-29 10:53:22 +05:30
parent c20833e9d7
commit e3e15f5584
8 changed files with 174 additions and 16 deletions

View File

@ -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]
})

View File

@ -117,5 +117,23 @@ private handleError<T>(operation = 'operation', result?: T) {
return of(result as T);
};
}
// generateotp(email):Observable<any>{
// return this._http.post(this.apiUrl+'generateOTP', '');
// }
generateotp(email): Observable<any> {
return this._http.post(this.apiUrl + 'generateOTP', { "records":{ "email":email}})
.pipe(
catchError(this.handleError('role', []))
)
}
resetpassword(data,otp): Observable<any> {
return this._http.post(this.apiUrl + 'verifyOTP', { "records":{ "email":data,"OTP":otp}})
.pipe(
catchError(this.handleError('role', []))
)
}
}

View File

@ -16,7 +16,7 @@
justify-content: center !important;
}
.paragraph_change {
color: #fff !important;
color: #fff !important;
background-color: #e00201 !important;
// padding: 10px !important;
}

View File

@ -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<OtpComponent, any>;
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: `
<h5 class="mt-0">Forgot Password</h5>
<mat-form-field>
<input matInput placeholder="Enter OTP" #otp style="width: 100%;">
</mat-form-field>
<br>
<button mat-raised-button class="mat-green" type="submit" (click)="dialogRef.close(newpassword.value)">Submit</button>
`
})
export class OTP {
newpassword: any = newpassword;
confirmPassword: any = confirmPassword;
jazzMessage = 'Jazzy jazz jazz';
constructor(public dialogRef: MatDialogRef<ForgotPass>) {
}
}

View File

@ -1,3 +1,28 @@
<p>
otp works!
</p>
<h2 mat-dialog-title class="paragraph_change">
<div fxFlex="70" align="left" style="padding: 10px !important;">
OTP
</div>
<div fxFlex="30" align="end" style="padding: 10px !important;">
<button mat-raised-button mat-icon-button class="mr-1 mb-1 hover-icon" type="button" matTooltip="Close"
matTooltipPosition="right" mat-dialog-close>
<mat-icon>close</mat-icon>
</button>
</div>
</h2>
<mat-dialog-content>
<mat-form-field style="width: 80%">
<input matInput placeholder="Enter OTP" #otp
type="text" maxlength="6">
</mat-form-field>
</mat-dialog-content>
<mat-dialog-actions>
<div fxFlex="100" align="right">
<!--<button mat-raised-button mat-icon-button class="mr-1 mb-1 hover-icon" type="button" mat-dialog-close matTooltip="Close" matTooltipPosition="below"><mat-icon>close</mat-icon></button>-->
<button mat-raised-button mat-icon-button (click)="updatepassword(otp.value)" class="mr-1 mb-1 hover-icon" type="button" matTooltip="Update Password" matTooltipPosition="below"><mat-icon>save</mat-icon></button>
</div>
</mat-dialog-actions>

View File

@ -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;
}

View File

@ -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<OtpComponent>,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.!');
}
})
}
}

View File

@ -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 {}