fix `Finger/FaceID login
parent
0d05073e71
commit
0b4a7090ae
@ -1,226 +1,462 @@
|
|||||||
|
|
||||||
import { Component, OnInit } from "@angular/core";
|
import { Component, OnInit } from "@angular/core";
|
||||||
|
|
||||||
import { ElementRef } from "@angular/core";
|
import { ElementRef } from "@angular/core";
|
||||||
import { NavController } from "@ionic/angular";
|
|
||||||
|
import { NavController, Platform } from "@ionic/angular";
|
||||||
|
|
||||||
import { TranslatorService } from "src/app/hmg-common/services/translator/translator.service";
|
import { TranslatorService } from "src/app/hmg-common/services/translator/translator.service";
|
||||||
|
|
||||||
import { CommonService } from "src/app/hmg-common/services/common/common.service";
|
import { CommonService } from "src/app/hmg-common/services/common/common.service";
|
||||||
|
|
||||||
import { SharedDataService } from "src/app/hmg-common/services/shared-data-service/shared-data.service";
|
import { SharedDataService } from "src/app/hmg-common/services/shared-data-service/shared-data.service";
|
||||||
|
|
||||||
import { SMSCheckRequest } from "src/app/hmg-common/services/authentication/models/smscheck.request";
|
import { SMSCheckRequest } from "src/app/hmg-common/services/authentication/models/smscheck.request";
|
||||||
|
|
||||||
import { LoginModel } from "../models/LoginModel";
|
import { LoginModel } from "../models/LoginModel";
|
||||||
|
|
||||||
import { AuthenticationService } from "src/app/hmg-common/services/authentication/authentication.service";
|
import { AuthenticationService } from "src/app/hmg-common/services/authentication/authentication.service";
|
||||||
|
|
||||||
import { SMSCheckResponse } from "src/app/hmg-common/services/authentication/models/smscheck.response";
|
import { SMSCheckResponse } from "src/app/hmg-common/services/authentication/models/smscheck.response";
|
||||||
|
|
||||||
import { Password } from "../models/password";
|
import { Password } from "../models/password";
|
||||||
|
|
||||||
import { GetLoginInfoRequest } from 'src/app/hmg-common/services/authentication/models/get-login-info.request';
|
import { GetLoginInfoRequest } from 'src/app/hmg-common/services/authentication/models/get-login-info.request';
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
|
|
||||||
selector: "app-sms-page",
|
selector: "app-sms-page",
|
||||||
|
|
||||||
templateUrl: "./sms-page.page.html",
|
templateUrl: "./sms-page.page.html",
|
||||||
|
|
||||||
styleUrls: ["./sms-page.page.scss"]
|
styleUrls: ["./sms-page.page.scss"]
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
export class SmsPageComponent implements OnInit {
|
export class SmsPageComponent implements OnInit {
|
||||||
|
|
||||||
public static LOGIN_DATA = "LOGIN_DATA";
|
public static LOGIN_DATA = "LOGIN_DATA";
|
||||||
|
|
||||||
Channel: number = 0;
|
Channel: number = 0;
|
||||||
|
|
||||||
activationCode: string;
|
activationCode: string;
|
||||||
|
|
||||||
P_SESSION_ID: number;
|
P_SESSION_ID: number;
|
||||||
|
|
||||||
P_USER_NAME: string;
|
P_USER_NAME: string;
|
||||||
|
|
||||||
timeInSeconds: any;
|
timeInSeconds: any;
|
||||||
|
|
||||||
time: any;
|
time: any;
|
||||||
|
|
||||||
runTimer: any;
|
runTimer: any;
|
||||||
|
|
||||||
hasStarted: any;
|
hasStarted: any;
|
||||||
|
|
||||||
hasFinished: any;
|
hasFinished: any;
|
||||||
|
|
||||||
remainingTime: any;
|
remainingTime: any;
|
||||||
|
|
||||||
displayTime: any;
|
displayTime: any;
|
||||||
|
|
||||||
loginTokenID: string;
|
loginTokenID: string;
|
||||||
|
|
||||||
public isForgetPwd: boolean = false;
|
public isForgetPwd: boolean = false;
|
||||||
|
|
||||||
public isExpiredPwd: boolean = false;
|
public isExpiredPwd: boolean = false;
|
||||||
|
|
||||||
public count: number = 0;
|
public count: number = 0;
|
||||||
|
|
||||||
private loginData = new LoginModel();
|
private loginData = new LoginModel();
|
||||||
|
|
||||||
public deviceToken:any;
|
public deviceToken:any;
|
||||||
|
|
||||||
public loginTypeData:any;
|
public loginTypeData:any;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
|
|
||||||
public navCtrl: NavController,
|
public navCtrl: NavController,
|
||||||
|
|
||||||
public translate: TranslatorService,
|
public translate: TranslatorService,
|
||||||
|
|
||||||
public common: CommonService,
|
public common: CommonService,
|
||||||
|
|
||||||
private elementRef: ElementRef,
|
private elementRef: ElementRef,
|
||||||
|
|
||||||
public authService: AuthenticationService,
|
public authService: AuthenticationService,
|
||||||
public sharedData: SharedDataService
|
|
||||||
|
public sharedData: SharedDataService,
|
||||||
|
|
||||||
|
public platform: Platform,
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
|
|
||||||
this.count = 0;
|
this.count = 0;
|
||||||
|
|
||||||
this.initTimer();
|
this.initTimer();
|
||||||
|
|
||||||
this.startTimer();
|
this.startTimer();
|
||||||
|
|
||||||
this.isForgetPwd =
|
this.isForgetPwd =
|
||||||
|
|
||||||
this.sharedData.getSharedData(Password.IS_FORGET_PSW) || false;
|
this.sharedData.getSharedData(Password.IS_FORGET_PSW) || false;
|
||||||
|
|
||||||
this.isExpiredPwd =
|
this.isExpiredPwd =
|
||||||
|
|
||||||
this.sharedData.getSharedData(Password.IS_EXPIRED_PSW) || false;
|
this.sharedData.getSharedData(Password.IS_EXPIRED_PSW) || false;
|
||||||
|
|
||||||
this.loginData= this.sharedData.getSharedData(AuthenticationService.LOGIN_DATA, false);
|
this.loginData= this.sharedData.getSharedData(AuthenticationService.LOGIN_DATA, false);
|
||||||
|
|
||||||
console.log("loginData : "+ this.loginData);
|
console.log("loginData : "+ this.loginData);
|
||||||
|
|
||||||
this.deviceToken= this.common.sharedService.getSharedData(AuthenticationService.DEVICE_TOKEN, false);
|
this.deviceToken= this.common.sharedService.getSharedData(AuthenticationService.DEVICE_TOKEN, false);
|
||||||
|
|
||||||
if(this.deviceToken == undefined){
|
if(this.deviceToken == undefined){
|
||||||
|
|
||||||
this.deviceToken = localStorage.getItem("deviceToken");
|
this.deviceToken = localStorage.getItem("deviceToken");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log("deviceToken :"+this.deviceToken);
|
console.log("deviceToken :"+this.deviceToken);
|
||||||
|
|
||||||
this.loginTypeData= this.common.sharedService.getSharedData(SMSCheckRequest.SHARED_DATA, false);
|
this.loginTypeData= this.common.sharedService.getSharedData(SMSCheckRequest.SHARED_DATA, false);
|
||||||
|
|
||||||
console.log("loginType :"+this.loginTypeData.loginType);
|
console.log("loginType :"+this.loginTypeData.loginType);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
initTimer() {
|
initTimer() {
|
||||||
|
|
||||||
// Pomodoro is usually for 25 minutes
|
// Pomodoro is usually for 25 minutes
|
||||||
|
|
||||||
if (!this.timeInSeconds) {
|
if (!this.timeInSeconds) {
|
||||||
|
|
||||||
this.timeInSeconds = 600;
|
this.timeInSeconds = 600;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
this.time = this.timeInSeconds;
|
this.time = this.timeInSeconds;
|
||||||
|
|
||||||
this.runTimer = false;
|
this.runTimer = false;
|
||||||
|
|
||||||
this.hasStarted = false;
|
this.hasStarted = false;
|
||||||
|
|
||||||
this.hasFinished = false;
|
this.hasFinished = false;
|
||||||
|
|
||||||
this.remainingTime = this.timeInSeconds;
|
this.remainingTime = this.timeInSeconds;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
this.displayTime = this.common.getSecondsAsDigitalClock(this.remainingTime);
|
this.displayTime = this.common.getSecondsAsDigitalClock(this.remainingTime);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
startTimer() {
|
startTimer() {
|
||||||
|
|
||||||
this.runTimer = true;
|
this.runTimer = true;
|
||||||
|
|
||||||
this.hasStarted = true;
|
this.hasStarted = true;
|
||||||
|
|
||||||
this.timerTick();
|
this.timerTick();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
pauseTimer() {
|
pauseTimer() {
|
||||||
|
|
||||||
this.runTimer = false;
|
this.runTimer = false;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
resumeTimer() {
|
resumeTimer() {
|
||||||
|
|
||||||
this.startTimer();
|
this.startTimer();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
timerTick() {
|
timerTick() {
|
||||||
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
|
|
||||||
if (!this.runTimer) {
|
if (!this.runTimer) {
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this.remainingTime--;
|
this.remainingTime--;
|
||||||
|
|
||||||
this.displayTime = this.common.getSecondsAsDigitalClock(
|
this.displayTime = this.common.getSecondsAsDigitalClock(
|
||||||
|
|
||||||
this.remainingTime
|
this.remainingTime
|
||||||
|
|
||||||
);
|
);
|
||||||
|
|
||||||
if (this.remainingTime > 0) {
|
if (this.remainingTime > 0) {
|
||||||
|
|
||||||
this.timerTick();
|
this.timerTick();
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
this.hasFinished = true;
|
this.hasFinished = true;
|
||||||
|
|
||||||
this.pauseTimer();
|
this.pauseTimer();
|
||||||
|
|
||||||
this.navCtrl.pop();
|
this.navCtrl.pop();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}, 1000);
|
}, 1000);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
ionViewWillLeave() {
|
ionViewWillLeave() {
|
||||||
|
|
||||||
this.pauseTimer();
|
this.pauseTimer();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
checkOTPLength(){
|
checkOTPLength(){
|
||||||
|
|
||||||
console.log(this.activationCode.length);
|
console.log(this.activationCode.length);
|
||||||
|
|
||||||
if(this.activationCode.length==4){
|
if(this.activationCode.length==4){
|
||||||
|
|
||||||
this.checkVerificationCode();
|
this.checkVerificationCode();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
checkVerificationCode() {
|
checkVerificationCode() {
|
||||||
|
|
||||||
if (this.count < 3) {
|
if (this.count < 3) {
|
||||||
|
|
||||||
if (
|
if (
|
||||||
|
|
||||||
this.activationCode == undefined ||
|
this.activationCode == undefined ||
|
||||||
|
|
||||||
this.activationCode == null ||
|
this.activationCode == null ||
|
||||||
|
|
||||||
this.activationCode == ""
|
this.activationCode == ""
|
||||||
|
|
||||||
) {
|
) {
|
||||||
|
|
||||||
// this.common.showAlert(this.translate.translate('verificationcode.emptyCode'));
|
// this.common.showAlert(this.translate.translate('verificationcode.emptyCode'));
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
this.count = this.count + 1;
|
this.count = this.count + 1;
|
||||||
|
|
||||||
if (this.isForgetPwd || this.isExpiredPwd) {
|
if (this.isForgetPwd || this.isExpiredPwd) {
|
||||||
|
|
||||||
this.checkForgetPwdSMS();
|
this.checkForgetPwdSMS();
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
this.checkSMS();
|
this.checkSMS();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
let msg: string = this.translate.trPK("general", "noOfTriesLogin");
|
let msg: string = this.translate.trPK("general", "noOfTriesLogin");
|
||||||
|
|
||||||
this.common.JustAlertDialog(this.translate.trPK("general", "ok"), msg);
|
this.common.JustAlertDialog(this.translate.trPK("general", "ok"), msg);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public checkSMS() {
|
public checkSMS() {
|
||||||
|
|
||||||
// alert("checkSMS in page")
|
// alert("checkSMS in page")
|
||||||
|
|
||||||
const data = this.sharedData.getSharedData(AuthenticationService.LOGIN_DATA, false);
|
const data = this.sharedData.getSharedData(AuthenticationService.LOGIN_DATA, false);
|
||||||
|
|
||||||
const request = new SMSCheckRequest();
|
const request = new SMSCheckRequest();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
request.LogInTokenID = data.LogInTokenID;
|
request.LogInTokenID = data.LogInTokenID;
|
||||||
|
|
||||||
request.activationCode = this.activationCode;
|
request.activationCode = this.activationCode;
|
||||||
|
|
||||||
request.P_USER_NAME = data.P_USER_NAME;
|
request.P_USER_NAME = data.P_USER_NAME;
|
||||||
|
|
||||||
request.MobileNumber = data.MobileNumber;
|
request.MobileNumber = data.MobileNumber;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
this.authService
|
this.authService
|
||||||
|
|
||||||
.checkSMS(request, () => {}, this.translate.trPK("general", "ok"))
|
.checkSMS(request, () => {}, this.translate.trPK("general", "ok"))
|
||||||
|
|
||||||
.subscribe((result: SMSCheckResponse) => {
|
.subscribe((result: SMSCheckResponse) => {
|
||||||
|
|
||||||
console.log(result);
|
console.log(result);
|
||||||
|
|
||||||
if (this.common.validResponse(result)) {
|
if (this.common.validResponse(result)) {
|
||||||
|
|
||||||
AuthenticationService.servicePrivilage=result.Privilege_List;
|
AuthenticationService.servicePrivilage=result.Privilege_List;
|
||||||
|
|
||||||
this.authService.setAuthenticatedUser(result).subscribe(() => {
|
this.authService.setAuthenticatedUser(result).subscribe(() => {
|
||||||
|
|
||||||
//call insert Mobile Login
|
//call insert Mobile Login
|
||||||
this.insertMobileLogin();
|
|
||||||
|
|
||||||
|
|
||||||
|
if (this.platform.is("mobile")) {
|
||||||
|
|
||||||
|
this.insertMobileLogin();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
this.common.openHome();
|
this.common.openHome();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public insertMobileLogin(){
|
public insertMobileLogin(){
|
||||||
|
|
||||||
// alert("insertMobileLogin");
|
// alert("insertMobileLogin");
|
||||||
|
|
||||||
let request = new GetLoginInfoRequest();
|
let request = new GetLoginInfoRequest();
|
||||||
|
|
||||||
this.authService.setPublicFields(request);
|
this.authService.setPublicFields(request);
|
||||||
|
|
||||||
request.MobileNumber = this.loginData.MobileNumber;
|
request.MobileNumber = this.loginData.MobileNumber;
|
||||||
|
|
||||||
request.P_USER_NAME=this.loginData.P_USER_NAME;
|
request.P_USER_NAME=this.loginData.P_USER_NAME;
|
||||||
|
|
||||||
request.UserName=this.loginData.P_USER_NAME;
|
request.UserName=this.loginData.P_USER_NAME;
|
||||||
|
|
||||||
request.LogInTokenID =this.loginData.LogInTokenID;
|
request.LogInTokenID =this.loginData.LogInTokenID;
|
||||||
|
|
||||||
request.CompanyID =1;//CompanyID
|
request.CompanyID =1;//CompanyID
|
||||||
|
|
||||||
request.DeviceType= this.common.getDeviceType();
|
request.DeviceType= this.common.getDeviceType();
|
||||||
|
|
||||||
request.DeviceToken=this.deviceToken;
|
request.DeviceToken=this.deviceToken;
|
||||||
|
|
||||||
request.LoginType=this.loginTypeData.loginType;
|
request.LoginType=this.loginTypeData.loginType;
|
||||||
|
|
||||||
this.authService
|
this.authService
|
||||||
|
|
||||||
.insertMobileLoginInfo(
|
.insertMobileLoginInfo(
|
||||||
|
|
||||||
request,
|
request,
|
||||||
|
|
||||||
() => { },
|
() => { },
|
||||||
|
|
||||||
this.translate.trPK("general", "ok")
|
this.translate.trPK("general", "ok")
|
||||||
|
|
||||||
)
|
)
|
||||||
|
|
||||||
.subscribe((result: any) => {
|
.subscribe((result: any) => {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
console.log("successful insertMobileLogin" );
|
console.log("successful insertMobileLogin" );
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public checkForgetPwdSMS() {
|
public checkForgetPwdSMS() {
|
||||||
|
|
||||||
const data = this.sharedData.getSharedData(AuthenticationService.LOGIN_DATA, false);
|
const data = this.sharedData.getSharedData(AuthenticationService.LOGIN_DATA, false);
|
||||||
|
|
||||||
const request = new SMSCheckRequest();
|
const request = new SMSCheckRequest();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
request.LogInTokenID = data.LogInTokenID;
|
request.LogInTokenID = data.LogInTokenID;
|
||||||
|
|
||||||
request.activationCode = this.activationCode;
|
request.activationCode = this.activationCode;
|
||||||
|
|
||||||
request.P_USER_NAME = data.P_USER_NAME;
|
request.P_USER_NAME = data.P_USER_NAME;
|
||||||
|
|
||||||
console.log(data.LogInTokenID);
|
console.log(data.LogInTokenID);
|
||||||
|
|
||||||
console.log(data.P_USER_NAME);
|
console.log(data.P_USER_NAME);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
this.authService
|
this.authService
|
||||||
|
|
||||||
.checkForgetSMS(request, () => {}, this.translate.trPK("general", "ok"))
|
.checkForgetSMS(request, () => {}, this.translate.trPK("general", "ok"))
|
||||||
|
|
||||||
.subscribe((result: SMSCheckResponse) => {
|
.subscribe((result: SMSCheckResponse) => {
|
||||||
|
|
||||||
console.log(result);
|
console.log(result);
|
||||||
|
|
||||||
if (this.common.validResponse(result)) {
|
if (this.common.validResponse(result)) {
|
||||||
|
|
||||||
console.log(result);
|
console.log(result);
|
||||||
|
|
||||||
if (this.isForgetPwd) {
|
if (this.isForgetPwd) {
|
||||||
|
|
||||||
this.common.openForgotPassword();
|
this.common.openForgotPassword();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(this.isExpiredPwd) {
|
if(this.isExpiredPwd) {
|
||||||
|
|
||||||
this.sharedData.setSharedData(true,Password.IS_EXPIRED_PSW);
|
this.sharedData.setSharedData(true,Password.IS_EXPIRED_PSW);
|
||||||
|
|
||||||
this.common.openChangePassword();
|
this.common.openChangePassword();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
Loading…
Reference in New Issue