forgot otp added

This commit is contained in:
venbainfotech 2022-02-07 18:13:03 +05:30
parent 639b820845
commit 022740c53e
9 changed files with 153 additions and 10 deletions

View File

@ -55,6 +55,7 @@ import { ReqTokenInterceptor } from './_guard/req-token.interceptor';
import { MatVideoModule } from 'mat-video'; import { MatVideoModule } from 'mat-video';
import { MAT_DATE_LOCALE } from '@angular/material/core'; import { MAT_DATE_LOCALE } from '@angular/material/core';
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) { export function HttpLoaderFactory(http: HttpClient) {
return new TranslateHttpLoader(http); return new TranslateHttpLoader(http);
} }
@ -74,8 +75,7 @@ export function createTranslateLoader(http: HttpClient) {
AuthLayoutComponent, AuthLayoutComponent,
NewPasswordDialog,ForgotPass,ChangePasswordDialog, RoleMenuItemsPipe, NewPasswordDialog,ForgotPass,ChangePasswordDialog, RoleMenuItemsPipe,
HttpLoaderComponent, HttpLoaderComponent,
DialogOverviewExampleDialog DialogOverviewExampleDialog,OtpComponent
], ],
imports: [ imports: [
@ -134,7 +134,7 @@ export function createTranslateLoader(http: HttpClient) {
}, },
{ provide:MAT_DATE_LOCALE, useValue: 'en-GB' } { provide:MAT_DATE_LOCALE, useValue: 'en-GB' }
], ],
entryComponents: [NewPasswordDialog,ForgotPass,ChangePasswordDialog], entryComponents: [NewPasswordDialog,ForgotPass,ChangePasswordDialog,OtpComponent],
bootstrap: [AppComponent] bootstrap: [AppComponent]
}) })
export class AppModule { } export class AppModule { }

View File

@ -24,5 +24,19 @@ export class DashboardService {
getCommonSettingsConfig(){ getCommonSettingsConfig(){
return this._http.post(this.apiUrl+'getCommonConfig', ''); return this._http.post(this.apiUrl+'getCommonConfig', '');
} }
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

@ -53,8 +53,7 @@ export class SalesPdComponent implements OnInit {
console.log(userDetails); console.log(userDetails);
let role= this.constantProvider.takeDecisionRouting(JSON.parse(userDetails)) let role= this.constantProvider.takeDecisionRouting(JSON.parse(userDetails))
console.log(role) console.log(role)
if(role == 'sales'){ if(role == 'sales'){
this.is_sales_login = true this.is_sales_login = true
this.getListofPD() this.getListofPD()
@ -63,7 +62,7 @@ export class SalesPdComponent implements OnInit {
this.is_sales_login = false this.is_sales_login = false
this.getListofPD() this.getListofPD()
} }
},2000) },5000)
setTimeout(()=>{ setTimeout(()=>{
this.common = JSON.parse(localStorage.getItem('commonSettings')) this.common = JSON.parse(localStorage.getItem('commonSettings'))

View File

@ -15,6 +15,7 @@ import { MatDialog, MatDialogRef, MatDialogConfig } from '@angular/material';
import { CognitoService } from '../../AwsService/cognito.service'; import { CognitoService } from '../../AwsService/cognito.service';
import { DashboardService } from 'app/dashboard/dashboard.service'; import { DashboardService } from 'app/dashboard/dashboard.service';
import { LoaderService } from 'app/shared/loaderService/loader.service'; import { LoaderService } from 'app/shared/loaderService/loader.service';
import { OtpComponent } from '../otp/otp.component';
@Component({ @Component({
selector: 'ms-login-session', selector: 'ms-login-session',
@ -42,6 +43,7 @@ export class LoginComponent implements OnInit{
} }
}; };
commonDetails: any; commonDetails: any;
dialogRef: MatDialogRef<OtpComponent, any>;
constructor( constructor(
private router: Router, public aws: AwsService, public dialog: MatDialog, private router: Router, public aws: AwsService, public dialog: MatDialog,
public shared:CognitoService,private dashBoardService:DashboardService , private loaderService:LoaderService) { public shared:CognitoService,private dashBoardService:DashboardService , private loaderService:LoaderService) {
@ -114,10 +116,29 @@ export class LoginComponent implements OnInit{
forgotpassword() { forgotpassword() {
let auth = { 'Username': this.email }; this.dashBoardService.generateotp(this.email).subscribe(
this.aws.userforgotpass(auth).subscribe(res => { 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(){ loggedInCheck(){
//alert(this.shared.isLoggedIn); //alert(this.shared.isLoggedIn);

View File

@ -0,0 +1,28 @@
<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

@ -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<OtpComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ OtpComponent ]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(OtpComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

View File

@ -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<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,6 +17,7 @@ import { ForgotPasswordComponent } from './forgot-password/forgot-password.compo
import { LockScreenComponent } from './lockscreen/lockscreen.component'; import { LockScreenComponent } from './lockscreen/lockscreen.component';
import { SessionRoutes } from './session.routing'; import { SessionRoutes } from './session.routing';
import { OtpComponent } from './otp/otp.component';
@NgModule({ @NgModule({
imports: [ imports: [
@ -37,7 +38,7 @@ import { SessionRoutes } from './session.routing';
LoginComponent, LoginComponent,
RegisterComponent, RegisterComponent,
ForgotPasswordComponent, ForgotPasswordComponent,
LockScreenComponent, LockScreenComponent
] ]
}) })