|
|
|
|
@ -12,7 +12,7 @@ import { GetLoginInfoResponse } from '../../hmg-common/services/authentication/m
|
|
|
|
|
import { SMSCheckRequest } from 'src/app/hmg-common/services/authentication/models/smscheck.request';
|
|
|
|
|
import { SMSCheckResponse } from 'src/app/hmg-common/services/authentication/models/smscheck.response';
|
|
|
|
|
import { PushService } from 'src/app/hmg-common/services/push/push.service';
|
|
|
|
|
import { ModalController, Platform } from '@ionic/angular';
|
|
|
|
|
import { ModalController, Platform, AlertController } from '@ionic/angular';
|
|
|
|
|
import { CheckUserAuthenticationResponse } from 'src/app/hmg-common/services/authentication/models/check-user-auth.response';
|
|
|
|
|
import { LoginModel } from '../models/LoginModel';
|
|
|
|
|
import * as moment from 'moment';
|
|
|
|
|
@ -20,6 +20,8 @@ import { CheckAppVersionResponse } from 'src/app/hmg-common/services/authenticat
|
|
|
|
|
import { NFC } from "@ionic-native/nfc/ngx";
|
|
|
|
|
import { DigitalIdComponent } from '../digital-id/digital-id.component';
|
|
|
|
|
import { AppUpdateComponent } from '../app-update/app-update.component';
|
|
|
|
|
import { Password } from '../models/password';
|
|
|
|
|
import { CheckUserAuthenticationRequest } from 'src/app/hmg-common/services/authentication/models/check-user-auth.request';
|
|
|
|
|
|
|
|
|
|
@Component({
|
|
|
|
|
selector: 'app-confirm-login',
|
|
|
|
|
@ -54,7 +56,7 @@ export class ConfirmLoginComponent implements OnInit {
|
|
|
|
|
direction: string;
|
|
|
|
|
userInfo: any;
|
|
|
|
|
public businessInfo: object;
|
|
|
|
|
|
|
|
|
|
private checkUserResult: CheckUserAuthenticationResponse;
|
|
|
|
|
constructor(
|
|
|
|
|
public ts: TranslatorService,
|
|
|
|
|
public cs: CommonService,
|
|
|
|
|
@ -64,6 +66,7 @@ export class ConfirmLoginComponent implements OnInit {
|
|
|
|
|
public pushService: PushService,
|
|
|
|
|
public platform: Platform,
|
|
|
|
|
public modalController: ModalController,
|
|
|
|
|
public alertController: AlertController,
|
|
|
|
|
private nfc: NFC
|
|
|
|
|
) {
|
|
|
|
|
this.loginData = this.sharedData.getSharedData(AuthenticationService.LOGIN_DATA, false);
|
|
|
|
|
@ -376,7 +379,7 @@ export class ConfirmLoginComponent implements OnInit {
|
|
|
|
|
job_ar: result.MemberInformationList[0].JOB_NAME_Ar,
|
|
|
|
|
mobile: result.MemberInformationList[0].MobileNumberWithZipCode,
|
|
|
|
|
qr: result.MemberInformationList[0].BusinessCardQR,
|
|
|
|
|
company_logo: result.BC_Logo ? result.BC_Logo: result.CompanyImageURL,
|
|
|
|
|
company_logo: result.BC_Logo ? result.BC_Logo : result.CompanyImageURL,
|
|
|
|
|
company_url: result.BC_Domain,
|
|
|
|
|
company_type: result.CompanyMainCompany,
|
|
|
|
|
email: result.MemberInformationList[0].EMPLOYEE_EMAIL_ADDRESS
|
|
|
|
|
@ -446,13 +449,77 @@ export class ConfirmLoginComponent implements OnInit {
|
|
|
|
|
this.confirm(this.loginType);
|
|
|
|
|
} else {
|
|
|
|
|
if (result.IsPasswordExpired) {
|
|
|
|
|
// alert("dont forget to handelpresentPasswordExpiredDialog() ");
|
|
|
|
|
// this.presentPasswordExpiredDialog(); *****
|
|
|
|
|
this.presentPasswordExpiredDialog();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async presentPasswordExpiredDialog() {
|
|
|
|
|
const alert = await this.alertController.create({
|
|
|
|
|
header: this.ts.trPK('general', 'confirm'),
|
|
|
|
|
message: this.ts.trPK('login', 'password-expired'),
|
|
|
|
|
buttons: [
|
|
|
|
|
{
|
|
|
|
|
text: this.ts.trPK('general', 'ok'),
|
|
|
|
|
handler: () => {
|
|
|
|
|
console.log('Confirm Okay');
|
|
|
|
|
this.sharedData.setSharedData(true, Password.IS_EXPIRED_PSW);
|
|
|
|
|
this.userCheck();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
]
|
|
|
|
|
});
|
|
|
|
|
await alert.present();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public userCheck() {
|
|
|
|
|
this.cs.startLoading();
|
|
|
|
|
const request = new CheckUserAuthenticationRequest();
|
|
|
|
|
request.P_USER_NAME = this.username;
|
|
|
|
|
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 sendSMSForForgotPassword() {
|
|
|
|
|
this.cs.startLoading();
|
|
|
|
|
const changePwdObj = new LoginRequest();
|
|
|
|
|
changePwdObj.MobileNumber = this.checkUserResult.BasicMemberInformation.P_MOBILE_NUMBER;
|
|
|
|
|
changePwdObj.P_USER_NAME = this.username;
|
|
|
|
|
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.username;
|
|
|
|
|
// this.loginData.EmployeeName =result.MemberLoginList[0].EMPLOYEE_NAME;
|
|
|
|
|
|
|
|
|
|
this.cs.sharedService.setSharedData(this.loginData.P_USER_NAME, LoginRequest.SHARED_DATA);
|
|
|
|
|
this.sharedData.setSharedData(this.loginData, AuthenticationService.LOGIN_DATA);
|
|
|
|
|
this.sharedData.setSharedData(true, Password.IS_FORGET_PSW);
|
|
|
|
|
this.cs.stopLoading();
|
|
|
|
|
this.cs.openSMSPage();
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private handleAppUpdate(result) {
|
|
|
|
|
this.iosLink = result.IOSLink;
|
|
|
|
|
this.androidLink = result.AndroidLink;
|
|
|
|
|
@ -478,14 +545,14 @@ export class ConfirmLoginComponent implements OnInit {
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async appUpdate(msg, result) {
|
|
|
|
|
async appUpdate(msg, result) {
|
|
|
|
|
const modal = await this.modalController.create({
|
|
|
|
|
component: AppUpdateComponent,
|
|
|
|
|
cssClass: 'app-update-modal-css',
|
|
|
|
|
componentProps: {'msg':msg}
|
|
|
|
|
componentProps: { 'msg': msg }
|
|
|
|
|
});
|
|
|
|
|
modal.onDidDismiss().then((data) => {
|
|
|
|
|
this.handleAppUpdate(result);
|
|
|
|
|
this.handleAppUpdate(result);
|
|
|
|
|
});
|
|
|
|
|
return await modal.present();
|
|
|
|
|
}
|
|
|
|
|
@ -517,9 +584,9 @@ export class ConfirmLoginComponent implements OnInit {
|
|
|
|
|
let buttonSelected;
|
|
|
|
|
this.buttons.forEach(element => {
|
|
|
|
|
element.forEach(elementValue => {
|
|
|
|
|
if(typeNumber === elementValue.value){
|
|
|
|
|
if (typeNumber === elementValue.value) {
|
|
|
|
|
buttonSelected = elementValue;
|
|
|
|
|
}else{
|
|
|
|
|
} else {
|
|
|
|
|
elementValue.visible = false;
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|