|
|
|
|
@ -26,7 +26,6 @@ import { KeyboardStatusModel } from 'src/app/hmg-common/services/keyboard/keyboa
|
|
|
|
|
})
|
|
|
|
|
export class LoginComponent implements OnInit, OnDestroy {
|
|
|
|
|
deviceToken1: any;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
constructor(
|
|
|
|
|
public cs: CommonService,
|
|
|
|
|
@ -45,7 +44,6 @@ export class LoginComponent implements OnInit, OnDestroy {
|
|
|
|
|
public pushService: PushService,
|
|
|
|
|
public keyboardService: KeyboardService
|
|
|
|
|
) {
|
|
|
|
|
|
|
|
|
|
this.events.subscribe('logoutFlage', logoutFlage => {
|
|
|
|
|
console.log('login compont logoutFlage: ' + logoutFlage);
|
|
|
|
|
// tslint:disable-next-line: triple-equals
|
|
|
|
|
@ -55,20 +53,18 @@ export class LoginComponent implements OnInit, OnDestroy {
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
appLang = 1;
|
|
|
|
|
isExpired = false;
|
|
|
|
|
isSupportAr = false;
|
|
|
|
|
@ -99,17 +95,9 @@ export class LoginComponent implements OnInit, OnDestroy {
|
|
|
|
|
getuser: any = '';
|
|
|
|
|
getlastlogin: any;
|
|
|
|
|
public keyboardOpened = false;
|
|
|
|
|
|
|
|
|
|
private checkUserResult: CheckUserAuthenticationResponse;
|
|
|
|
|
|
|
|
|
|
ngOnInit() {
|
|
|
|
|
// if(!this.cs.getIsTimeSessionOut()){
|
|
|
|
|
// this.getlastlogin = this.cs.sharedService.getSharedData(
|
|
|
|
|
// AuthenticationService.IMEI_USER_DATA,
|
|
|
|
|
// false
|
|
|
|
|
// );
|
|
|
|
|
// console.log("this.getlastlogin"+ this.getlastlogin);
|
|
|
|
|
// }
|
|
|
|
|
this.monitorKeyboardChange();
|
|
|
|
|
this.currentLang = TranslatorService.getCurrentLanguageCode();
|
|
|
|
|
console.log(TranslatorService.CURRENT_LANGUAGE)
|
|
|
|
|
@ -121,38 +109,11 @@ export class LoginComponent implements OnInit, OnDestroy {
|
|
|
|
|
this.language = "AR";
|
|
|
|
|
this.changeLanguage('1')
|
|
|
|
|
}
|
|
|
|
|
console.log("current lang: "+this.currentLang)
|
|
|
|
|
//this.ts.switchLanguage();
|
|
|
|
|
// 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;
|
|
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
console.log("current lang: "+this.currentLang);
|
|
|
|
|
this.events.subscribe('user', user => {
|
|
|
|
|
this.user = user;
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
//this.deviceToken = localStorage.getItem('devicyeToken');
|
|
|
|
|
//this.deviceToken1 =this.cs.getDeviceToken();
|
|
|
|
|
|
|
|
|
|
console.log(" this.user login in init" + this.user);
|
|
|
|
|
//this.deviceToken = localStorage.getItem('devicyeToken');
|
|
|
|
|
this.deviceToken =this.cs.getDeviceToken();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
console.log('lngOnInit localStorage: ' + this.deviceToken1);
|
|
|
|
|
console.log('lngOnInit getDeviceToken: ' + this.deviceToken);
|
|
|
|
|
|
|
|
|
|
if (this.deviceToken) {
|
|
|
|
|
console.log('login enabled first time: ' + this.deviceToken);
|
|
|
|
|
} else {
|
|
|
|
|
@ -160,7 +121,7 @@ export class LoginComponent implements OnInit, OnDestroy {
|
|
|
|
|
this.pushService.startReceiving();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// here will delete below part and depdding on user (response from getMobileInfo)
|
|
|
|
|
// here will delete below part and depdding on user (response from getMobileInfo)
|
|
|
|
|
this.username = localStorage.getItem('user');
|
|
|
|
|
this.password = localStorage.getItem('password'); // ****//
|
|
|
|
|
const remember = localStorage.getItem('remember'); // ****//
|
|
|
|
|
@ -192,6 +153,7 @@ export class LoginComponent implements OnInit, OnDestroy {
|
|
|
|
|
}
|
|
|
|
|
this.currentLang = langNumber;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public forgetPasswordPage() {
|
|
|
|
|
this.cs.openUserForgot();
|
|
|
|
|
}
|
|
|
|
|
@ -214,12 +176,12 @@ export class LoginComponent implements OnInit, OnDestroy {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public onLogin() {
|
|
|
|
|
this.deviceToken = localStorage.getItem('deviceToken');
|
|
|
|
|
if (this.deviceToken) {
|
|
|
|
|
this.deviceToken = localStorage.getItem('deviceToken');
|
|
|
|
|
if (this.deviceToken) {
|
|
|
|
|
this.checkAppUpdated();
|
|
|
|
|
} else {
|
|
|
|
|
this.pushService.startReceiving();
|
|
|
|
|
setTimeout(() => {
|
|
|
|
|
} else {
|
|
|
|
|
this.pushService.startReceiving();
|
|
|
|
|
setTimeout(() => {
|
|
|
|
|
this.deviceToken = localStorage.getItem('deviceToken');
|
|
|
|
|
this.checkAppUpdated();
|
|
|
|
|
console.log('login enabled second time: ' + this.deviceToken);
|
|
|
|
|
@ -228,10 +190,7 @@ export class LoginComponent implements OnInit, OnDestroy {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public checkAppUpdated() {
|
|
|
|
|
this.authService.checkApplicationVersion(
|
|
|
|
|
() => {
|
|
|
|
|
/* Write code for error */
|
|
|
|
|
}).subscribe((result: CheckAppVersionResponse) => {
|
|
|
|
|
this.authService.checkApplicationVersion(() => {}).subscribe((result: CheckAppVersionResponse) => {
|
|
|
|
|
// tslint:disable-next-line: triple-equals
|
|
|
|
|
if (result.MessageStatus == 2 && result.ErrorType == 4) {
|
|
|
|
|
this.cs.presentAcceptDialog(result.ErrorEndUserMessage, () => {
|
|
|
|
|
@ -258,12 +217,14 @@ export class LoginComponent implements OnInit, OnDestroy {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private checkUserAuthentication() {
|
|
|
|
|
console.log('debug Here!!');
|
|
|
|
|
console.log(this.username);
|
|
|
|
|
console.log(this.language);
|
|
|
|
|
console.log(this.password);
|
|
|
|
|
public isValidForm(): boolean {
|
|
|
|
|
if (this.username && this.password) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private checkUserAuthentication() {
|
|
|
|
|
this.cs.startLoading();
|
|
|
|
|
const request = new LoginRequest();
|
|
|
|
|
request.P_USER_NAME = this.username;
|
|
|
|
|
@ -273,16 +234,12 @@ export class LoginComponent implements OnInit, OnDestroy {
|
|
|
|
|
this.authService
|
|
|
|
|
.login(request, () => {
|
|
|
|
|
console.log('error here');
|
|
|
|
|
// console.log(result.MessageStatus);
|
|
|
|
|
// this.sharedData.setSharedData(true, Password.IS_EXPIRED_PSW);
|
|
|
|
|
// this.userCheck();
|
|
|
|
|
}, this.ts.trPK('general', 'ok'))
|
|
|
|
|
.subscribe((result: CheckUserAuthenticationResponse) => {
|
|
|
|
|
console.log('success');
|
|
|
|
|
this.cs.stopLoading();
|
|
|
|
|
if (this.cs.validResponse(result)) {
|
|
|
|
|
// alert("result.MemberLoginList.EMPLOYEE_NAME :" + result.MemberLoginList[0].EMPLOYEE_NAME);
|
|
|
|
|
|
|
|
|
|
this.loginData.LogInTokenID = result.LogInTokenID;
|
|
|
|
|
this.loginData.MobileNumber = result.MemberLoginList.P_MOBILE_NUMBER;
|
|
|
|
|
this.loginData.P_USER_NAME = this.username;
|
|
|
|
|
@ -294,8 +251,6 @@ export class LoginComponent implements OnInit, OnDestroy {
|
|
|
|
|
// if(!this.welcomeBack){
|
|
|
|
|
this.cs.openConfirmLoginPage(); // phase#2 add 4 types for OTP
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
console.log('result.IsPasswordExpired');
|
|
|
|
|
console.log(result.IsPasswordExpired);
|
|
|
|
|
@ -386,7 +341,6 @@ export class LoginComponent implements OnInit, OnDestroy {
|
|
|
|
|
}
|
|
|
|
|
console.log('login emit');
|
|
|
|
|
console.log('login');
|
|
|
|
|
// this.checkUserAuthentication();
|
|
|
|
|
// this.loginDiv=true;
|
|
|
|
|
this.user = false;
|
|
|
|
|
}
|
|
|
|
|
@ -397,9 +351,6 @@ export class LoginComponent implements OnInit, OnDestroy {
|
|
|
|
|
this.cs.openConfirmLoginPage();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
///
|
|
|
|
|
|
|
|
|
|
getLastLoginInfo() {
|
|
|
|
|
this.requestGetLoginInfo = {
|
|
|
|
|
DeviceType: this.cs.getDeviceType(), // "Android",//this.cs.getDeviceType(),
|
|
|
|
|
@ -419,7 +370,6 @@ export class LoginComponent implements OnInit, OnDestroy {
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
this.user = false;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|