|
|
|
|
@ -2,7 +2,7 @@ import { Component, OnInit, NgZone, 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, Platform } from "@ionic/angular";
|
|
|
|
|
import { AlertController, Platform, Events } 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";
|
|
|
|
|
@ -49,6 +49,8 @@ export class LoginComponent implements OnInit, OnDestroy {
|
|
|
|
|
user: boolean =false;
|
|
|
|
|
DeviceType: string;
|
|
|
|
|
requestGetLoginInfo:any;
|
|
|
|
|
logoutFlage: boolean ;
|
|
|
|
|
getuser:any="";
|
|
|
|
|
|
|
|
|
|
constructor(
|
|
|
|
|
public cs: CommonService,
|
|
|
|
|
@ -58,40 +60,89 @@ export class LoginComponent implements OnInit, OnDestroy {
|
|
|
|
|
public ts: TranslatorService,
|
|
|
|
|
public smsService: SmsReaderService,
|
|
|
|
|
private faio: FingerprintAIO,
|
|
|
|
|
public events:Events,
|
|
|
|
|
public ngZone: NgZone,
|
|
|
|
|
public device: Device,
|
|
|
|
|
public splash: SplashScreen,
|
|
|
|
|
public sharedData: SharedDataService,
|
|
|
|
|
public plt: Platform,
|
|
|
|
|
public pushService: PushService
|
|
|
|
|
) { }
|
|
|
|
|
) {
|
|
|
|
|
this.events.subscribe("logoutFlage", logoutFlage => {
|
|
|
|
|
console.log("login compont logoutFlage: "+logoutFlage);
|
|
|
|
|
if(logoutFlage == true){
|
|
|
|
|
console.log(" subscribe check logoutFlage: "+logoutFlage);
|
|
|
|
|
this.logoutFlage = logoutFlage;
|
|
|
|
|
localStorage.setItem('logoutFlage',logoutFlage);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
this.getuser = this.cs.sharedService.getSharedData(
|
|
|
|
|
AuthenticationService.IMEI_USER_DATA,
|
|
|
|
|
false
|
|
|
|
|
);
|
|
|
|
|
// alert(" this.getuser "+this.getuser);
|
|
|
|
|
if(this.getuser){
|
|
|
|
|
this.user = true;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
else{
|
|
|
|
|
this.user = false;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ngOnInit() {
|
|
|
|
|
// this.deviceToken= this.cs.sharedService.getSharedData(AuthenticationService.DEVICE_TOKEN, false);
|
|
|
|
|
// console.log("get deviceToken login"+ this.deviceToken)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// this.getuser = this.cs.sharedService.getSharedData(
|
|
|
|
|
// AuthenticationService.IMEI_USER_DATA,
|
|
|
|
|
// false
|
|
|
|
|
// );
|
|
|
|
|
|
|
|
|
|
// if(this.getuser){
|
|
|
|
|
// console.log("this.getuser"+this.getuser);
|
|
|
|
|
// this.logoutFlage = true;
|
|
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
this.events.subscribe("user", user => {
|
|
|
|
|
console.log("login compont: "+user);
|
|
|
|
|
this.user = user;
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.deviceToken= localStorage.getItem('devicyeToken');
|
|
|
|
|
console.log("let deviceToken" + this.deviceToken);
|
|
|
|
|
console.log("let deviceToken" + this.deviceToken);
|
|
|
|
|
|
|
|
|
|
if (this.deviceToken) {
|
|
|
|
|
console.log('login enabled first time: ' + this.deviceToken);
|
|
|
|
|
console.log('login enabled first time: ' + this.deviceToken);
|
|
|
|
|
} else {
|
|
|
|
|
console.log("no deviceToken" );
|
|
|
|
|
|
|
|
|
|
this.pushService.startReceiving();
|
|
|
|
|
setTimeout(() => {
|
|
|
|
|
this.deviceToken= localStorage.getItem('deviceToken');
|
|
|
|
|
console.log('login enabled second time: ' + this.deviceToken);
|
|
|
|
|
// alert('login enabled second time: ' + this.deviceToken);
|
|
|
|
|
|
|
|
|
|
}, 1000);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
setTimeout(() => {
|
|
|
|
|
// setTimeout(() => {
|
|
|
|
|
// alert("this.logoutFlage in setTime" +localStorage.getItem('logoutFlage'));
|
|
|
|
|
// alert("this.this.user in setTime" + this.user);
|
|
|
|
|
|
|
|
|
|
// if(localStorage.getItem('logoutFlage')== "true"){
|
|
|
|
|
// this.getLastLoginInfo();
|
|
|
|
|
|
|
|
|
|
this.getLastLoginInfo();
|
|
|
|
|
},5000);
|
|
|
|
|
// }
|
|
|
|
|
// },1000);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -355,12 +406,14 @@ export class LoginComponent implements OnInit, OnDestroy {
|
|
|
|
|
|
|
|
|
|
getLastLoginInfo(){
|
|
|
|
|
this.requestGetLoginInfo= {
|
|
|
|
|
DeviceType:this.cs.getDeviceType(),
|
|
|
|
|
DeviceType:this.cs.getDeviceType(),//"Android",//this.cs.getDeviceType(),
|
|
|
|
|
DeviceToken:this.deviceToken//"5ca8a69cf1804db55264c349edffb99b9d63acd9fa9b6b18956bcb2ad3f2ba36"//this.deviceToken
|
|
|
|
|
}
|
|
|
|
|
this.authService.getLoginInfo(this.requestGetLoginInfo,() => {}, this.ts.trPK('general', 'ok')).subscribe(res => {
|
|
|
|
|
if (this.cs.validResponse(res)) {
|
|
|
|
|
|
|
|
|
|
if(res.Mohemm_GetMobileLoginInfoList.length > 0){
|
|
|
|
|
|
|
|
|
|
this.cs.sharedService.setSharedData(
|
|
|
|
|
// res.Patient_SELECTDeviceIMEIbyIMEIList[0],
|
|
|
|
|
res.Mohemm_GetMobileLoginInfoList[0],
|
|
|
|
|
|