fixed session issue

MOHEMM-Q3-DEV-LATEST
umasoodch 5 years ago
parent 05647d71ef
commit 426bfb86ca

@ -654,11 +654,37 @@ export class AuthenticationService {
this.ts.trPK("general", "idle-relogin"),
() => {
this.cs.sharedService.clearAll();
this.cs.openLogin();
// this.cs.openLogin();
this.getLastLoginInfo();
}
);
}
public getLastLoginInfo() {
let deviceToken = localStorage.getItem('deviceToken');
const requestGetLoginInfo = {
DeviceType: this.cs.getDeviceType(),
DeviceToken: deviceToken
};
this.getLoginInfo(requestGetLoginInfo, () => {}, this.ts.trPK('general', 'ok')).subscribe(res => {
if (this.cs.validResponse(res)) {
if (res.Mohemm_GetMobileLoginInfoList.length > 0) {
this.cs.sharedService.setSharedData(res.Mohemm_GetMobileLoginInfoList[0], AuthenticationService.IMEI_USER_DATA);
const user = true;
this.events.publish('user', user);
this.cs.openLogin();
} else {
const user = false;
this.events.publish('user', user);
this.cs.openLogin();
}
} else {}
});
}
/*
reset and start idling interval
*/

@ -9,6 +9,10 @@ import { catchError, retry, tap, timeout } from 'rxjs/operators';
import { CommonService } from '../common/common.service';
// import { Response } from "../models/response";
import { Response } from 'src/app/hmg-common/services/models/response';
import { Events } from "@ionic/angular";
import { GetLoginInfoResponse } from "src/app/hmg-common/services/authentication/models/get-login-info.response";
import { GetLoginInfoRequest } from "src/app/hmg-common/services/authentication/models/get-login-info.request";
import { TranslatorService } from "../translator/translator.service";
@Injectable({
providedIn: 'root'
@ -26,7 +30,10 @@ export class ConnectorService {
// public static host = 'https://uat.hmgwebservices.com/';
public static host = 'https://hmgwebservices.com/';
constructor(public httpClient: HttpClient, public cs: CommonService) {}
constructor(public httpClient: HttpClient,
public cs: CommonService,
private events: Events,
public ts: TranslatorService) {}
public post(
service: string,
@ -173,6 +180,44 @@ export class ConnectorService {
}
}
public getLoginInfo(
request: any,
onError: any,
errorLabel: string
): Observable<GetLoginInfoResponse> {
//this.setPublicFields(request);
return this.post(
'Services/ERP.svc/REST/Mohemm_GetMobileLoginInfo_NEW',
request,
onError,
errorLabel
);
}
public getLastLoginInfo() {
let deviceToken = localStorage.getItem('deviceToken');
const requestGetLoginInfo = {
DeviceType: this.cs.getDeviceType(),
DeviceToken: deviceToken
};
this.getLoginInfo(requestGetLoginInfo, () => {}, this.ts.trPK('general', 'ok')).subscribe(res => {
if (this.cs.validResponse(res)) {
if (res.Mohemm_GetMobileLoginInfoList.length > 0) {
this.cs.sharedService.setSharedData(res.Mohemm_GetMobileLoginInfoList[0], 'imei-user-data');
const user = true;
this.events.publish('user', user);
this.cs.openLogin();
} else {
const user = false;
this.events.publish('user', user);
this.cs.openLogin();
}
} else {}
});
}
public handleResponse(result: Response, onError: any, errorLabel: string, isPostNoLoad = false) {
if (!isPostNoLoad) {
this.cs.stopLoading();
@ -182,8 +227,8 @@ export class ConnectorService {
this.cs.stopLoading();
this.cs.presentAcceptDialog(result.ErrorEndUserMessage, () => {
this.cs.sharedService.clearAll();
this.cs.openLogin();
// this.cs.openLogin();
this.getLastLoginInfo();
});
return false;
} else if (result.ErrorType === 2 || result.ErrorType === 4) {
@ -212,9 +257,9 @@ export class ConnectorService {
this.cs.stopLoading();
this.cs.presentAcceptDialog(result.ErrorEndUserMessage, () => {
console.log("presentAcceptDialog");
this.cs.sharedService.clearAll();
this.cs.openLogin();
this.cs.sharedService.clearAll();
// this.cs.openLogin();
this.getLastLoginInfo();
});
return false;
} else if (result.ErrorType === 2 || result.ErrorType === 4) {

Loading…
Cancel
Save