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.
88 lines
4.0 KiB
TypeScript
88 lines
4.0 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 { CheckUserAuthenticationRequest } from 'src/app/hmg-common/services/authentication/models/check-user-auth.request';
|
|
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 { InternationalMobileComponent } from 'src/app/hmg-common/ui/mobile-number/international-mobile/international-mobile.component';
|
|
import { LoginRequest } from 'src/app/hmg-common/services/authentication/models/login.request';
|
|
import { SharedDataService } from 'src/app/hmg-common/services/shared-data-service/shared-data.service';
|
|
import { Password } from '../models/password';
|
|
import { LoginModel } from '../models/LoginModel';
|
|
import {LoginComponent} from 'src/app/authentication/login/login.component';
|
|
@Component({
|
|
selector: 'app-check-user',
|
|
templateUrl: './check-user.component.html',
|
|
styleUrls: ['./check-user.component.scss'],
|
|
})
|
|
export class CheckUserComponent implements OnInit {
|
|
public P_USER_NAME : string;
|
|
private loginData = new LoginModel();
|
|
public logo = "assets/icon/login/lock.png";
|
|
|
|
@ViewChild(InternationalMobileComponent) internationlMobile: InternationalMobileComponent;
|
|
constructor(public cs: CommonService,
|
|
public authService: AuthenticationService,
|
|
public router: Router,
|
|
public alertController: AlertController,
|
|
public ts: TranslatorService,
|
|
public smsService: SmsReaderService,
|
|
public sharedData: SharedDataService,
|
|
public changeDetector: ChangeDetectorRef) { }
|
|
|
|
ngOnInit() {}
|
|
|
|
public onForgot() {
|
|
this.sendSMSForForgotPassword();
|
|
}
|
|
|
|
public userCheck()
|
|
{
|
|
this.cs.startLoading();
|
|
const request = new CheckUserAuthenticationRequest();
|
|
request.P_USER_NAME = this.P_USER_NAME;
|
|
this.authService.checkUserAuthentication(
|
|
request,
|
|
() => {
|
|
/* Write code for error */
|
|
}, this.ts.trPK('general', 'ok')).subscribe((result: CheckUserAuthenticationResponse) => {
|
|
if (this.cs.validResponse(result)) {
|
|
this.checkUserResult = result;
|
|
this.cs.stopLoading();
|
|
this.sendSMSForForgotPassword();
|
|
}
|
|
});
|
|
}
|
|
|
|
private checkUserResult: CheckUserAuthenticationResponse;
|
|
|
|
private sendSMSForForgotPassword() {
|
|
this.cs.startLoading();
|
|
let changePwdObj= new LoginRequest();
|
|
changePwdObj.MobileNumber= this.checkUserResult.BasicMemberInformation.P_MOBILE_NUMBER;
|
|
changePwdObj.P_USER_NAME=this.P_USER_NAME;
|
|
changePwdObj.P_MOBILE_NUMBER=this.checkUserResult.BasicMemberInformation.P_MOBILE_NUMBER;
|
|
|
|
this.authService.sendPublicSMS(
|
|
changePwdObj,
|
|
() => {
|
|
//this.sendSMSForForgotPassword();
|
|
/* Write code for error */
|
|
}, this.ts.trPK('general', 'ok')).subscribe((result: CheckUserAuthenticationResponse) => {
|
|
if (this.cs.validResponse(result)) {
|
|
this.checkUserResult = result;
|
|
console.log("2");
|
|
console.log(result);
|
|
this.loginData.LogInTokenID = result.LogInTokenID;
|
|
this.loginData.P_USER_NAME = this.P_USER_NAME;
|
|
// this.loginData.EMPLOYEE_NAME=result.MemberLoginList[0].EMPLOYEE_NAME;
|
|
this.sharedData.setSharedData(this.loginData, AuthenticationService.LOGIN_DATA);
|
|
this.sharedData.setSharedData(true,Password.IS_FORGET_PSW);
|
|
this.cs.stopLoading();
|
|
this.cs.openSMSPage();
|
|
}});
|
|
}
|
|
} |