You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
mohemmionic5/Mohem/src/app/authentication/forgot/forgot.component.ts

81 lines
3.2 KiB
TypeScript

import { Component, OnInit, ViewChild, ChangeDetectorRef, OnDestroy } from '@angular/core';
import { CommonService } from 'src/app/hmg-common/services/common/common.service';
import { AuthenticationService } from 'src/app/hmg-common/services/authentication/authentication.service';
import { Router } from '@angular/router';
import { AlertController } from '@ionic/angular';
import { TranslatorService } from 'src/app/hmg-common/services/translator/translator.service';
import { CheckUserAuthenticationResponse } from 'src/app/hmg-common/services/authentication/models/check-user-auth.response';
import { SmsReaderService } from 'src/app/hmg-common/services/sms/sms-reader.service';
import { ForgetPassword } from '../models/forget.password';
import { LoginModel } from '../models/LoginModel';
import { SharedDataService } from 'src/app/hmg-common/services/shared-data-service/shared-data.service';
import {LoginComponent} from "src/app/authentication/login/login.component";
@Component({
selector: 'app-forgot',
templateUrl: './forgot.component.html',
styleUrls: ['./forgot.component.scss']
})
7 years ago
export class ForgotComponent implements OnInit {
private loginData = new LoginModel();
public P_NEW_PASSWORD: string;
public P_Confirm_NEW_PASSWORD : string;
public P_USER_NAME : string;
constructor(
public cs: CommonService,
public authService: AuthenticationService,
public router: Router,
public alertController: AlertController,
public ts: TranslatorService,
public smsService: SmsReaderService,
public changeDetector: ChangeDetectorRef,
public sharedData: SharedDataService
) {
}
ngOnInit() {
}
public onForgot() {
this.sendSMSForForgotPassword();
}
private checkUserResult: CheckUserAuthenticationResponse;
private sendSMSForForgotPassword() {
const request = new ForgetPassword();
this.authService.sendForgetPassword(
request,
() => {
this.sendSMSForForgotPassword();
}, this.ts.trPK('general', 'ok')).subscribe((result: CheckUserAuthenticationResponse) => {
if (this.cs.validResponse(result)) {
this.checkUserResult = result;
}
});
}
public forgotpassword(){
const data = this.sharedData.getSharedData(AuthenticationService.LOGIN_DATA, false);
this.loginData.P_USER_NAME = this.P_USER_NAME;
let request:ForgetPassword = new ForgetPassword();
request.P_Confirm_NEW_PASSWORD=this.P_NEW_PASSWORD;
request.P_NEW_PASSWORD=this.P_Confirm_NEW_PASSWORD;
request.P_USER_NAME = data.P_USER_NAME;
7 years ago
this.authService.submitForgetPassword(
request,
() => {
//this.sendSMSForForgotPassword();
}, this.ts.trPK('general', 'ok')).subscribe((result: CheckUserAuthenticationResponse) => {
if (this.cs.validResponse(result)) {
this.checkUserResult = result;
console.log(result);
7 years ago
this.cs.toastPK("changePassword","successChange");
this.cs.openLogin();
}
});
}
}