otp changes

This commit is contained in:
venbatechnologies@gmail.com 2022-02-03 18:31:37 +05:30
parent 119da953dd
commit 2971b7efbe
8 changed files with 156 additions and 6 deletions

View File

@ -54,9 +54,11 @@ import { environment } from '../environments/environment';
import { ReqTokenInterceptor } from './_guard/req-token.interceptor'; 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 { AdvanceFilterComponent } from './sales-pd/sales-pd-list/advance-filter/advance-filter.component'; //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 { 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);
} }
@ -76,6 +78,7 @@ export function createTranslateLoader(http: HttpClient) {
AuthLayoutComponent, AuthLayoutComponent,
NewPasswordDialog,ForgotPass,ChangePasswordDialog, RoleMenuItemsPipe, NewPasswordDialog,ForgotPass,ChangePasswordDialog, RoleMenuItemsPipe,
HttpLoaderComponent, HttpLoaderComponent,
OtpComponent,
// AdvanceFilterComponent, // AdvanceFilterComponent,
DialogOverviewExampleDialog DialogOverviewExampleDialog
], ],
@ -134,7 +137,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,15 @@ 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}})
}
resetpassword(data,otp): Observable<any> {
return this._http.post(this.apiUrl + 'verifyOTP', { "records":{ "email":data,"OTP":otp}})
}
} }

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) {
@ -99,6 +101,27 @@ export class LoginComponent implements OnInit{
this.loaderService.closeMatSpinnerDialog(); this.loaderService.closeMatSpinnerDialog();
//alert(err.message); //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 * New password set
@ -125,13 +148,13 @@ export class LoginComponent implements OnInit{
} }
forgotpassword() { // forgotpassword() {
let auth = { 'Username': this.email }; // let auth = { 'Username': this.email };
this.aws.userforgotpass(auth).subscribe(res => { // this.aws.userforgotpass(auth).subscribe(res => {
}) // })
} // }
loggedInCheck(){ loggedInCheck(){
//alert(this.shared.isLoggedIn); //alert(this.shared.isLoggedIn);
if(this.shared.isLoggedIn){ if(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,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<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

@ -18,6 +18,7 @@ import { LockScreenComponent } from './lockscreen/lockscreen.component';
import { SessionRoutes } from './session.routing'; import { SessionRoutes } from './session.routing';
@NgModule({ @NgModule({
imports: [ imports: [
CommonModule, CommonModule,
@ -38,6 +39,7 @@ import { SessionRoutes } from './session.routing';
RegisterComponent, RegisterComponent,
ForgotPasswordComponent, ForgotPasswordComponent,
LockScreenComponent, LockScreenComponent,
] ]
}) })