|
|
|
|
@ -38,87 +38,96 @@ import { SendActivationByType } from 'src/app/authentication/models/sendActivati
|
|
|
|
|
})
|
|
|
|
|
export class AuthenticationService {
|
|
|
|
|
|
|
|
|
|
/* login methods */
|
|
|
|
|
public static loginURL = 'Services/Authentication.svc/REST/CheckPatientAuthentication';
|
|
|
|
|
public static checkUserAuthURL = 'Services/Authentication.svc/REST/CheckPatientAuthentication';
|
|
|
|
|
|
|
|
|
|
public static login = 'Services/ERP.svc/REST/MemberLogin';
|
|
|
|
|
|
|
|
|
|
public static activationCodeURL = 'Services/Authentication.svc/REST/CheckActivationCode';
|
|
|
|
|
public static getLoginInfoURL = 'Services/Authentication.svc/REST/GetMobileLoginInfo';
|
|
|
|
|
|
|
|
|
|
public static smsCheck='Services/ERP.svc/REST/CheckActivationCode';
|
|
|
|
|
public static smsCheckForget='Services/ERP.svc/REST/CheckPublicActivationCode';
|
|
|
|
|
public static smsSendCode='Services/ERP.svc/REST/SendPublicActivationCode';
|
|
|
|
|
|
|
|
|
|
public static sendActivationCodeByType = 'Services/ERP.svc/REST/Mohemm_SendActivationCodebyOTPNotificationType';
|
|
|
|
|
public static getMobileLoginInfo ='Services/ERP.svc/REST/Mohemm_GetMobileLoginInfo_NEW';//Mohemm_GetMobileLoginInfo
|
|
|
|
|
public static insertMobileLoginInfo ='Services/ERP.svc/REST/Mohemm_InsertMobileLoginInfo';
|
|
|
|
|
|
|
|
|
|
/* register methods */
|
|
|
|
|
|
|
|
|
|
public static checkPatientForRegisterationURL = 'Services/Authentication.svc/REST/CheckPatientForRegisteration';
|
|
|
|
|
public static sendSmsForRegisterURL = 'Services/Authentication.svc/REST/SendSMSForPatientRegisteration';
|
|
|
|
|
public static registerTempUserURL = 'Services/Authentication.svc/REST/RegisterTempPatientWithoutSMS';
|
|
|
|
|
|
|
|
|
|
public static sendSMSForgotFileNoURL = 'Services/Authentication.svc/REST/SendPatientIDSMSByMobileNumber';
|
|
|
|
|
public static forgotFileIDURL = 'Services/Authentication.svc/REST/CheckActivationCodeForSendFileNo';
|
|
|
|
|
public static user: AuthenticatedUser;
|
|
|
|
|
public static servicePrivilage : PrivilageModel[];
|
|
|
|
|
|
|
|
|
|
/*user checking methods */
|
|
|
|
|
public static userChecking = 'Services/ERP.svc/REST/Get_BasicUserInformation';
|
|
|
|
|
public static changePasswordForget ='Services/ERP.svc/REST/ChangePassword_Forget';
|
|
|
|
|
public static changePassword ='Services/ERP.svc/REST/ChangePassword_FromActiveSession';
|
|
|
|
|
public static expiredPassword = 'Services/ERP.svc/REST/ChangePassword_Expired';
|
|
|
|
|
public static checkAppVersion = 'Services/Utilities.svc/REST/CheckMobileAppVersion';
|
|
|
|
|
|
|
|
|
|
public static LOGIN_EVENT = 'user-login-event';
|
|
|
|
|
public static FAMILY_LOGIN_EVENT = 'family-login-event';
|
|
|
|
|
public static AUTHENTICATED_USER_KEY = 'save-authenticated-user';
|
|
|
|
|
public static LOGIN_DATA="logindata";
|
|
|
|
|
public static DEVICE_TOKEN = "device_token";
|
|
|
|
|
public static LAST_LOGIN = 'last-login';
|
|
|
|
|
public static IMEI_USER_DATA = "imei-user-data";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// private static user: AuthenticatedUser;
|
|
|
|
|
constructor(
|
|
|
|
|
public con: ConnectorService,
|
|
|
|
|
public cs: CommonService,
|
|
|
|
|
public ts: TranslatorService,
|
|
|
|
|
public nativeStorage: NativeStorage,
|
|
|
|
|
// public localNotifications: UserLocalNotificationService,
|
|
|
|
|
private events: Events,
|
|
|
|
|
private menu: MenuController,
|
|
|
|
|
public platform: Platform
|
|
|
|
|
) { }
|
|
|
|
|
|
|
|
|
|
public authenticateRequest(request: Request, automaticLogin = true): Request {
|
|
|
|
|
|
|
|
|
|
this.setPublicFields(request);
|
|
|
|
|
const user = this.getAuthenticatedUser();
|
|
|
|
|
if (user) {
|
|
|
|
|
request.P_SESSION_ID = user.P_SESSION_ID;
|
|
|
|
|
request.MobileNumber = user.EMPLOYEE_MOBILE_NUMBER;
|
|
|
|
|
request.LogInTokenID = user.LogInTokenID;
|
|
|
|
|
request.TokenID = user.TokenID;
|
|
|
|
|
request.P_USER_NAME = user.EMPLOYEE_NUMBER;
|
|
|
|
|
request.UserName = user.EMPLOYEE_NUMBER;
|
|
|
|
|
request.P_EMAIL_ADDRESS = user.EMPLOYEE_EMAIL_ADDRESS;
|
|
|
|
|
if (AuthenticationService.requireRelogin) {
|
|
|
|
|
this.sessionTimeOutDialog();
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
this.cs.userNeedToReLogin();
|
|
|
|
|
}
|
|
|
|
|
/*
|
|
|
|
|
else {
|
|
|
|
|
if (automaticLogin) {
|
|
|
|
|
this.cs.openUserLogin();
|
|
|
|
|
}
|
|
|
|
|
/* login methods */
|
|
|
|
|
public static loginURL = 'Services/Authentication.svc/REST/CheckPatientAuthentication';
|
|
|
|
|
public static checkUserAuthURL = 'Services/Authentication.svc/REST/CheckPatientAuthentication';
|
|
|
|
|
|
|
|
|
|
public static login = 'Services/ERP.svc/REST/MemberLogin';
|
|
|
|
|
|
|
|
|
|
public static activationCodeURL = 'Services/Authentication.svc/REST/CheckActivationCode';
|
|
|
|
|
public static getLoginInfoURL = 'Services/Authentication.svc/REST/GetMobileLoginInfo';
|
|
|
|
|
|
|
|
|
|
public static smsCheck = 'Services/ERP.svc/REST/CheckActivationCode';
|
|
|
|
|
public static smsCheckForget = 'Services/ERP.svc/REST/CheckPublicActivationCode';
|
|
|
|
|
public static smsSendCode = 'Services/ERP.svc/REST/SendPublicActivationCode';
|
|
|
|
|
|
|
|
|
|
public static sendActivationCodeByType = 'Services/ERP.svc/REST/Mohemm_SendActivationCodebyOTPNotificationType';
|
|
|
|
|
public static getMobileLoginInfo = 'Services/ERP.svc/REST/Mohemm_GetMobileLoginInfo_NEW';//Mohemm_GetMobileLoginInfo
|
|
|
|
|
public static insertMobileLoginInfo = 'Services/ERP.svc/REST/Mohemm_InsertMobileLoginInfo';
|
|
|
|
|
|
|
|
|
|
/* register methods */
|
|
|
|
|
|
|
|
|
|
public static checkPatientForRegisterationURL = 'Services/Authentication.svc/REST/CheckPatientForRegisteration';
|
|
|
|
|
public static sendSmsForRegisterURL = 'Services/Authentication.svc/REST/SendSMSForPatientRegisteration';
|
|
|
|
|
public static registerTempUserURL = 'Services/Authentication.svc/REST/RegisterTempPatientWithoutSMS';
|
|
|
|
|
|
|
|
|
|
public static sendSMSForgotFileNoURL = 'Services/Authentication.svc/REST/SendPatientIDSMSByMobileNumber';
|
|
|
|
|
public static forgotFileIDURL = 'Services/Authentication.svc/REST/CheckActivationCodeForSendFileNo';
|
|
|
|
|
public static user: AuthenticatedUser;
|
|
|
|
|
public static servicePrivilage: PrivilageModel[];
|
|
|
|
|
|
|
|
|
|
/*user checking methods */
|
|
|
|
|
public static userChecking = 'Services/ERP.svc/REST/Get_BasicUserInformation';
|
|
|
|
|
public static changePasswordForget = 'Services/ERP.svc/REST/ChangePassword_Forget';
|
|
|
|
|
public static changePassword = 'Services/ERP.svc/REST/ChangePassword_FromActiveSession';
|
|
|
|
|
public static expiredPassword = 'Services/ERP.svc/REST/ChangePassword_Expired';
|
|
|
|
|
public static checkAppVersion = 'Services/Utilities.svc/REST/CheckMobileAppVersion';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* check survey or ads */
|
|
|
|
|
|
|
|
|
|
public static getITGPageNotification = 'Services/COCWS.svc/REST/Mohemm_ITG_GetPageNotification';
|
|
|
|
|
public static getITGPageNotificationDetails = 'Services/COCWS.svc/REST/Mohemm_ITG_GetPageNotificationDetails';
|
|
|
|
|
public static saveSurveyAds = 'Services/COCWS.svc/REST/Mohemm_ITG_Survey_Response';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static LOGIN_EVENT = 'user-login-event';
|
|
|
|
|
public static FAMILY_LOGIN_EVENT = 'family-login-event';
|
|
|
|
|
public static AUTHENTICATED_USER_KEY = 'save-authenticated-user';
|
|
|
|
|
public static LOGIN_DATA = "logindata";
|
|
|
|
|
public static DEVICE_TOKEN = "device_token";
|
|
|
|
|
public static LAST_LOGIN = 'last-login';
|
|
|
|
|
public static IMEI_USER_DATA = "imei-user-data";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// private static user: AuthenticatedUser;
|
|
|
|
|
constructor(
|
|
|
|
|
public con: ConnectorService,
|
|
|
|
|
public cs: CommonService,
|
|
|
|
|
public ts: TranslatorService,
|
|
|
|
|
public nativeStorage: NativeStorage,
|
|
|
|
|
// public localNotifications: UserLocalNotificationService,
|
|
|
|
|
private events: Events,
|
|
|
|
|
private menu: MenuController,
|
|
|
|
|
public platform: Platform
|
|
|
|
|
) { }
|
|
|
|
|
|
|
|
|
|
public authenticateRequest(request: Request, automaticLogin = true): Request {
|
|
|
|
|
|
|
|
|
|
this.setPublicFields(request);
|
|
|
|
|
const user = this.getAuthenticatedUser();
|
|
|
|
|
if (user) {
|
|
|
|
|
request.P_SESSION_ID = user.P_SESSION_ID;
|
|
|
|
|
request.MobileNumber = user.EMPLOYEE_MOBILE_NUMBER;
|
|
|
|
|
request.LogInTokenID = user.LogInTokenID;
|
|
|
|
|
request.TokenID = user.TokenID;
|
|
|
|
|
request.P_USER_NAME = user.EMPLOYEE_NUMBER;
|
|
|
|
|
request.UserName = user.EMPLOYEE_NUMBER;
|
|
|
|
|
request.P_EMAIL_ADDRESS = user.EMPLOYEE_EMAIL_ADDRESS;
|
|
|
|
|
if (AuthenticationService.requireRelogin) {
|
|
|
|
|
this.sessionTimeOutDialog();
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
this.cs.userNeedToReLogin();
|
|
|
|
|
}
|
|
|
|
|
/*
|
|
|
|
|
else {
|
|
|
|
|
if (automaticLogin) {
|
|
|
|
|
this.cs.openUserLogin();
|
|
|
|
|
}
|
|
|
|
|
*/
|
|
|
|
|
}
|
|
|
|
|
*/
|
|
|
|
|
return request;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -127,17 +136,17 @@ export class AuthenticationService {
|
|
|
|
|
const isIOS = this.platform.is('ios');
|
|
|
|
|
let mobileType = '';
|
|
|
|
|
if (isAndroid) {
|
|
|
|
|
mobileType = 'android';
|
|
|
|
|
mobileType = 'android';
|
|
|
|
|
} else if (isIOS) {
|
|
|
|
|
mobileType = 'ios';
|
|
|
|
|
}else{
|
|
|
|
|
mobileType = 'android';
|
|
|
|
|
mobileType = 'ios';
|
|
|
|
|
} else {
|
|
|
|
|
mobileType = 'android';
|
|
|
|
|
}
|
|
|
|
|
request.VersionID = 2.9;
|
|
|
|
|
request.Channel = 31;
|
|
|
|
|
request.LanguageID = TranslatorService.getCurrentLanguageCode();
|
|
|
|
|
request.MobileType = mobileType;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return request;
|
|
|
|
|
}
|
|
|
|
|
public authenticateAndSetPersonalInformation(
|
|
|
|
|
@ -194,65 +203,65 @@ export class AuthenticationService {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public getPublicRequest(): Request {
|
|
|
|
|
const request = new Request();
|
|
|
|
|
this.setPublicFields(request);
|
|
|
|
|
return request;
|
|
|
|
|
}
|
|
|
|
|
public getPublicRequest(): Request {
|
|
|
|
|
const request = new Request();
|
|
|
|
|
this.setPublicFields(request);
|
|
|
|
|
return request;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public checkApplicationVersion(onError: any): Observable<CheckAppVersionResponse> {
|
|
|
|
|
const request = new Request();
|
|
|
|
|
this.setPublicFields(request);
|
|
|
|
|
return this.con.post(AuthenticationService.checkAppVersion, request, onError);
|
|
|
|
|
public checkApplicationVersion(onError: any): Observable<CheckAppVersionResponse> {
|
|
|
|
|
const request = new Request();
|
|
|
|
|
this.setPublicFields(request);
|
|
|
|
|
return this.con.post(AuthenticationService.checkAppVersion, request, onError);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public login(request: LoginRequest, onError: any, errorLabel: string): Observable<Response> {
|
|
|
|
|
this.setPublicFields(request);
|
|
|
|
|
request.P_APP_VERSION="CS";
|
|
|
|
|
return this.con.post(AuthenticationService.login, request, onError, errorLabel);
|
|
|
|
|
public login(request: LoginRequest, onError: any, errorLabel: string): Observable<Response> {
|
|
|
|
|
this.setPublicFields(request);
|
|
|
|
|
request.P_APP_VERSION = "CS";
|
|
|
|
|
return this.con.post(AuthenticationService.login, request, onError, errorLabel);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public isAuthenticated(): boolean {
|
|
|
|
|
return AuthenticationService.user != null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* this fucntion load from user information if he logged in before
|
|
|
|
|
* and save user into memory and local storage
|
|
|
|
|
* disable notifications for previous user if new user logged in with different user
|
|
|
|
|
*
|
|
|
|
|
*
|
|
|
|
|
* info:
|
|
|
|
|
* 1- user stored in local storage without token
|
|
|
|
|
* @param result check activation code result
|
|
|
|
|
*/
|
|
|
|
|
public setAuthenticatedUser(
|
|
|
|
|
result: SMSCheckResponse
|
|
|
|
|
): Observable<boolean> {
|
|
|
|
|
return Observable.create(observer => {
|
|
|
|
|
this.loadAuthenticatedUser().subscribe(
|
|
|
|
|
(loadedUser: AuthenticatedUser) => {
|
|
|
|
|
AuthenticationService.requireRelogin = false;
|
|
|
|
|
this.startIdleMonitoring();
|
|
|
|
|
const user = this.updateAuthenticatedUser(result, loadedUser);
|
|
|
|
|
/* we store in hd without token but with token in memory*/
|
|
|
|
|
this.saveUserInStorage(user).subscribe((success: boolean) => {
|
|
|
|
|
AuthenticationService.user = user;
|
|
|
|
|
|
|
|
|
|
this.publishUserChangeEvent();
|
|
|
|
|
observer.next(true);
|
|
|
|
|
observer.complete();
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public isAuthenticated(): boolean {
|
|
|
|
|
return AuthenticationService.user != null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* this fucntion load from user information if he logged in before
|
|
|
|
|
* and save user into memory and local storage
|
|
|
|
|
* disable notifications for previous user if new user logged in with different user
|
|
|
|
|
*
|
|
|
|
|
*
|
|
|
|
|
* info:
|
|
|
|
|
* 1- user stored in local storage without token
|
|
|
|
|
* @param result check activation code result
|
|
|
|
|
*/
|
|
|
|
|
public setAuthenticatedUser(
|
|
|
|
|
result: SMSCheckResponse
|
|
|
|
|
): Observable<boolean> {
|
|
|
|
|
return Observable.create(observer => {
|
|
|
|
|
this.loadAuthenticatedUser().subscribe(
|
|
|
|
|
(loadedUser: AuthenticatedUser) => {
|
|
|
|
|
AuthenticationService.requireRelogin = false;
|
|
|
|
|
this.startIdleMonitoring();
|
|
|
|
|
const user = this.updateAuthenticatedUser(result, loadedUser);
|
|
|
|
|
/* we store in hd without token but with token in memory*/
|
|
|
|
|
this.saveUserInStorage(user).subscribe((success: boolean) => {
|
|
|
|
|
AuthenticationService.user = user;
|
|
|
|
|
|
|
|
|
|
this.publishUserChangeEvent();
|
|
|
|
|
observer.next(true);
|
|
|
|
|
observer.complete();
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public resetAuthenticatedUser(user: AuthenticatedUser) {
|
|
|
|
|
AuthenticationService.user = user;
|
|
|
|
|
AuthenticationService.requireRelogin = false;
|
|
|
|
|
@ -334,8 +343,8 @@ export class AuthenticationService {
|
|
|
|
|
user.P_SESSION_ID = result.P_SESSION_ID;
|
|
|
|
|
user.MobileNumber = result.EMPLOYEE_MOBILE_NUMBER;
|
|
|
|
|
user.TokenID = result.TokenID;
|
|
|
|
|
user.CompanyImageDescription=result.CompanyImageDescription;
|
|
|
|
|
user.CompanyImageURL=result.CompanyImageURL;
|
|
|
|
|
user.CompanyImageDescription = result.CompanyImageDescription;
|
|
|
|
|
user.CompanyImageURL = result.CompanyImageURL;
|
|
|
|
|
user.CompanyBadge = result.CompanyBadge;
|
|
|
|
|
user.CompanyMainCompany = result.CompanyMainCompany;
|
|
|
|
|
user.LogInTokenID = this.cs.sharedService.getSharedData(
|
|
|
|
|
@ -455,163 +464,163 @@ export class AuthenticationService {
|
|
|
|
|
return AuthenticationService.user;
|
|
|
|
|
}
|
|
|
|
|
*/
|
|
|
|
|
if(AuthenticationService.user){
|
|
|
|
|
return AuthenticationService.user;
|
|
|
|
|
}else{
|
|
|
|
|
this.cs.openLogin();
|
|
|
|
|
}
|
|
|
|
|
if (AuthenticationService.user) {
|
|
|
|
|
return AuthenticationService.user;
|
|
|
|
|
} else {
|
|
|
|
|
this.cs.openLogin();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public checkUserAuthentication(request: CheckUserAuthenticationRequest, onError: any, errorLabel: string)
|
|
|
|
|
: Observable<CheckUserAuthenticationResponse> {
|
|
|
|
|
this.setPublicFields(request);
|
|
|
|
|
request.P_APP_VERSION="CS";
|
|
|
|
|
return this.con.post(AuthenticationService.userChecking, request, onError, errorLabel);
|
|
|
|
|
}
|
|
|
|
|
public checkUserAuthentication(request: CheckUserAuthenticationRequest, onError: any, errorLabel: string)
|
|
|
|
|
: Observable<CheckUserAuthenticationResponse> {
|
|
|
|
|
this.setPublicFields(request);
|
|
|
|
|
request.P_APP_VERSION = "CS";
|
|
|
|
|
return this.con.post(AuthenticationService.userChecking, request, onError, errorLabel);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public checkActivationCode(request: CheckActivationCodeRequest, onError: any, errorLabel: string)
|
|
|
|
|
: Observable<CheckActivationCodeResponse> {
|
|
|
|
|
this.setPublicFields(request);
|
|
|
|
|
return this.con.post(AuthenticationService.activationCodeURL, request, onError, errorLabel);
|
|
|
|
|
}
|
|
|
|
|
public checkActivationCode(request: CheckActivationCodeRequest, onError: any, errorLabel: string)
|
|
|
|
|
: Observable<CheckActivationCodeResponse> {
|
|
|
|
|
this.setPublicFields(request);
|
|
|
|
|
return this.con.post(AuthenticationService.activationCodeURL, request, onError, errorLabel);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public checkSMS(request: SMSCheckRequest, onError: any, errorLabel: string)
|
|
|
|
|
: Observable<SMSCheckResponse> {
|
|
|
|
|
this.setPublicFields(request);
|
|
|
|
|
return this.con.post(AuthenticationService.smsCheck, request, onError, errorLabel);
|
|
|
|
|
}
|
|
|
|
|
public checkSMS(request: SMSCheckRequest, onError: any, errorLabel: string)
|
|
|
|
|
: Observable<SMSCheckResponse> {
|
|
|
|
|
this.setPublicFields(request);
|
|
|
|
|
return this.con.post(AuthenticationService.smsCheck, request, onError, errorLabel);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public checkForgetSMS(request: SMSCheckRequest, onError: any, errorLabel: string)
|
|
|
|
|
: Observable<SMSCheckResponse> {
|
|
|
|
|
this.setPublicFields(request);
|
|
|
|
|
return this.con.post(AuthenticationService.smsCheckForget, request, onError, errorLabel);
|
|
|
|
|
}
|
|
|
|
|
public checkForgetSMS(request: SMSCheckRequest, onError: any, errorLabel: string)
|
|
|
|
|
: Observable<SMSCheckResponse> {
|
|
|
|
|
this.setPublicFields(request);
|
|
|
|
|
return this.con.post(AuthenticationService.smsCheckForget, request, onError, errorLabel);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public sendPublicSMS(request: SMSCheckRequest, onError: any, errorLabel: string)
|
|
|
|
|
: Observable<CheckUserAuthenticationResponse> {
|
|
|
|
|
this.setPublicFields(request);
|
|
|
|
|
return this.con.post(AuthenticationService.smsSendCode, request, onError, errorLabel);
|
|
|
|
|
}
|
|
|
|
|
public sendPublicSMS(request: SMSCheckRequest, onError: any, errorLabel: string)
|
|
|
|
|
: Observable<CheckUserAuthenticationResponse> {
|
|
|
|
|
this.setPublicFields(request);
|
|
|
|
|
return this.con.post(AuthenticationService.smsSendCode, request, onError, errorLabel);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
client side:
|
|
|
|
|
id no , mobile no , zip code
|
|
|
|
|
*/
|
|
|
|
|
/*
|
|
|
|
|
client side:
|
|
|
|
|
id no , mobile no , zip code
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
client side:
|
|
|
|
|
id no , mobile no , zip code
|
|
|
|
|
*/
|
|
|
|
|
// public sendSmsForPatientRegisteration(request: CheckPatientRegisterationRequest, onError: any, errorLabel: string)
|
|
|
|
|
// : Observable<CheckUserAuthenticationResponse> {
|
|
|
|
|
// this.setPublicFields(request);
|
|
|
|
|
// request.TokenID = '';
|
|
|
|
|
// request.isRegister = false;
|
|
|
|
|
// return this.con.post(AuthenticationService.sendSmsForRegisterURL, request, onError, errorLabel);
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
public checkRegisterationActivationCode(request: CheckRegisterationCodeRequest, onError: any, errorLabel: string)
|
|
|
|
|
: Observable<Response> {
|
|
|
|
|
this.setPublicFields(request);
|
|
|
|
|
return this.con.post(AuthenticationService.activationCodeURL, request, onError, errorLabel);
|
|
|
|
|
}
|
|
|
|
|
// public sendSmsForPatientRegisteration(request: CheckPatientRegisterationRequest, onError: any, errorLabel: string)
|
|
|
|
|
// : Observable<CheckUserAuthenticationResponse> {
|
|
|
|
|
// this.setPublicFields(request);
|
|
|
|
|
// request.TokenID = '';
|
|
|
|
|
// request.isRegister = false;
|
|
|
|
|
// return this.con.post(AuthenticationService.sendSmsForRegisterURL, request, onError, errorLabel);
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
public sendForgetPassword(request: ForgetPassword, onError: any, errorLabel: string)
|
|
|
|
|
: Observable<CheckUserAuthenticationResponse> {
|
|
|
|
|
this.setPublicFields(request);
|
|
|
|
|
return this.con.post(AuthenticationService.smsSendCode, request, onError, errorLabel);
|
|
|
|
|
}
|
|
|
|
|
public checkRegisterationActivationCode(request: CheckRegisterationCodeRequest, onError: any, errorLabel: string)
|
|
|
|
|
: Observable<Response> {
|
|
|
|
|
this.setPublicFields(request);
|
|
|
|
|
return this.con.post(AuthenticationService.activationCodeURL, request, onError, errorLabel);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public submitForgetPassword(request: ForgetPassword, onError: any, errorLabel: string)
|
|
|
|
|
: Observable<CheckUserAuthenticationResponse> {
|
|
|
|
|
this.setPublicFields(request);
|
|
|
|
|
return this.con.post(AuthenticationService.changePasswordForget, request, onError, errorLabel);
|
|
|
|
|
}
|
|
|
|
|
public sendForgetPassword(request: ForgetPassword, onError: any, errorLabel: string)
|
|
|
|
|
: Observable<CheckUserAuthenticationResponse> {
|
|
|
|
|
this.setPublicFields(request);
|
|
|
|
|
return this.con.post(AuthenticationService.smsSendCode, request, onError, errorLabel);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public submitChangePassword(request: ForgetPassword, onError: any, errorLabel: string)
|
|
|
|
|
: Observable<CheckUserAuthenticationResponse> {
|
|
|
|
|
this.setPublicFields(request);
|
|
|
|
|
this.authenticateRequest(request);
|
|
|
|
|
return this.con.post(AuthenticationService.changePassword, request, onError, errorLabel);
|
|
|
|
|
}
|
|
|
|
|
public submitForgetPassword(request: ForgetPassword, onError: any, errorLabel: string)
|
|
|
|
|
: Observable<CheckUserAuthenticationResponse> {
|
|
|
|
|
this.setPublicFields(request);
|
|
|
|
|
return this.con.post(AuthenticationService.changePasswordForget, request, onError, errorLabel);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public submitExpiredPassword(request: ForgetPassword, onError: any, errorLabel: string)
|
|
|
|
|
: Observable<CheckUserAuthenticationResponse> {
|
|
|
|
|
this.setPublicFields(request);
|
|
|
|
|
return this.con.post(AuthenticationService.expiredPassword, request, onError, errorLabel);
|
|
|
|
|
}
|
|
|
|
|
public submitChangePassword(request: ForgetPassword, onError: any, errorLabel: string)
|
|
|
|
|
: Observable<CheckUserAuthenticationResponse> {
|
|
|
|
|
this.setPublicFields(request);
|
|
|
|
|
this.authenticateRequest(request);
|
|
|
|
|
return this.con.post(AuthenticationService.changePassword, request, onError, errorLabel);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public sendSMSForForgotFileNumber(request: CheckUserAuthenticationRequest, onError: any, errorLabel: string)
|
|
|
|
|
: Observable<CheckUserAuthenticationResponse> {
|
|
|
|
|
this.setPublicFields(request);
|
|
|
|
|
request.TokenID = '';
|
|
|
|
|
//request.SearchType = 2;
|
|
|
|
|
//request.isRegister = false;
|
|
|
|
|
return this.con.post(AuthenticationService.sendSMSForgotFileNoURL, request, onError, errorLabel);
|
|
|
|
|
}
|
|
|
|
|
public submitExpiredPassword(request: ForgetPassword, onError: any, errorLabel: string)
|
|
|
|
|
: Observable<CheckUserAuthenticationResponse> {
|
|
|
|
|
this.setPublicFields(request);
|
|
|
|
|
return this.con.post(AuthenticationService.expiredPassword, request, onError, errorLabel);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public forgotFileIdActivation(request: CheckActivationCodeRequest, onError: any, errorLabel: string)
|
|
|
|
|
: Observable<ForgotFileIDResponse> {
|
|
|
|
|
this.setPublicFields(request);
|
|
|
|
|
request.TokenID = '';
|
|
|
|
|
request.SearchType = 2;
|
|
|
|
|
request.isRegister = false;
|
|
|
|
|
return this.con.post(AuthenticationService.forgotFileIDURL, request, onError, errorLabel);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public sendSMSForForgotFileNumber(request: CheckUserAuthenticationRequest, onError: any, errorLabel: string)
|
|
|
|
|
: Observable<CheckUserAuthenticationResponse> {
|
|
|
|
|
this.setPublicFields(request);
|
|
|
|
|
request.TokenID = '';
|
|
|
|
|
//request.SearchType = 2;
|
|
|
|
|
//request.isRegister = false;
|
|
|
|
|
return this.con.post(AuthenticationService.sendSMSForgotFileNoURL, request, onError, errorLabel);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// tslint:disable-next-line: max-line-length
|
|
|
|
|
public insertMobileLoginInfo(request: GetLoginInfoRequest, onError: any, errorLabel: string, isPostNoLoad = false): Observable<GetLoginInfoResponse> {
|
|
|
|
|
this.authenticateRequest(request);
|
|
|
|
|
if (isPostNoLoad) {
|
|
|
|
|
return this.con.postNoLoad(AuthenticationService.insertMobileLoginInfo, request, onError, errorLabel);
|
|
|
|
|
} else {
|
|
|
|
|
return this.con.post(AuthenticationService.insertMobileLoginInfo, request, onError, errorLabel);
|
|
|
|
|
}
|
|
|
|
|
public forgotFileIdActivation(request: CheckActivationCodeRequest, onError: any, errorLabel: string)
|
|
|
|
|
: Observable<ForgotFileIDResponse> {
|
|
|
|
|
this.setPublicFields(request);
|
|
|
|
|
request.TokenID = '';
|
|
|
|
|
request.SearchType = 2;
|
|
|
|
|
request.isRegister = false;
|
|
|
|
|
return this.con.post(AuthenticationService.forgotFileIDURL, request, onError, errorLabel);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// tslint:disable-next-line: max-line-length
|
|
|
|
|
public insertMobileLoginInfo(request: GetLoginInfoRequest, onError: any, errorLabel: string, isPostNoLoad = false): Observable<GetLoginInfoResponse> {
|
|
|
|
|
this.authenticateRequest(request);
|
|
|
|
|
if (isPostNoLoad) {
|
|
|
|
|
return this.con.postNoLoad(AuthenticationService.insertMobileLoginInfo, request, onError, errorLabel);
|
|
|
|
|
} else {
|
|
|
|
|
return this.con.post(AuthenticationService.insertMobileLoginInfo, request, onError, errorLabel);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public isSAUDIIDValid(id: string): boolean {
|
|
|
|
|
if (!id) {
|
|
|
|
|
public isSAUDIIDValid(id: string): boolean {
|
|
|
|
|
if (!id) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
try {
|
|
|
|
|
id = id.toString();
|
|
|
|
|
id = id.trim();
|
|
|
|
|
const returnValue = Number(id);
|
|
|
|
|
let sum = 0;
|
|
|
|
|
if (returnValue > 0) {
|
|
|
|
|
const type = Number(id.charAt(0));
|
|
|
|
|
|
|
|
|
|
if (id.length !== 10) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
try {
|
|
|
|
|
id = id.toString();
|
|
|
|
|
id = id.trim();
|
|
|
|
|
const returnValue = Number(id);
|
|
|
|
|
let sum = 0;
|
|
|
|
|
if (returnValue > 0) {
|
|
|
|
|
const type = Number(id.charAt(0));
|
|
|
|
|
|
|
|
|
|
if (id.length !== 10) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
if (type !== 2 && type !== 1) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (let i = 0; i < 10; i++) {
|
|
|
|
|
if (i % 2 === 0) {
|
|
|
|
|
const a = id.charAt(i);
|
|
|
|
|
const x = Number(a) * 2;
|
|
|
|
|
let b = x.toString();
|
|
|
|
|
if (b.length === 1) {
|
|
|
|
|
b = "0" + b;
|
|
|
|
|
}
|
|
|
|
|
sum += Number(b.charAt(0)) + Number(b.charAt(1));
|
|
|
|
|
} else {
|
|
|
|
|
sum += Number(id.charAt(i));
|
|
|
|
|
}
|
|
|
|
|
if (type !== 2 && type !== 1) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (let i = 0; i < 10; i++) {
|
|
|
|
|
if (i % 2 === 0) {
|
|
|
|
|
const a = id.charAt(i);
|
|
|
|
|
const x = Number(a) * 2;
|
|
|
|
|
let b = x.toString();
|
|
|
|
|
if (b.length === 1) {
|
|
|
|
|
b = "0" + b;
|
|
|
|
|
}
|
|
|
|
|
return sum % 10 === 0;
|
|
|
|
|
sum += Number(b.charAt(0)) + Number(b.charAt(1));
|
|
|
|
|
} else {
|
|
|
|
|
sum += Number(id.charAt(i));
|
|
|
|
|
}
|
|
|
|
|
} catch (err) {}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
return sum % 10 === 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} catch (err) { }
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public checkUserHasEmailDialog(): Observable<void> {
|
|
|
|
|
return Observable.create(observer => {
|
|
|
|
|
if (this.isAuthenticatedUserHasRealEmail()) {
|
|
|
|
|
@ -662,26 +671,26 @@ export class AuthenticationService {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public getLastLoginInfo() {
|
|
|
|
|
let deviceToken = localStorage.getItem('deviceToken');
|
|
|
|
|
let deviceToken = localStorage.getItem('deviceToken');
|
|
|
|
|
|
|
|
|
|
const requestGetLoginInfo = {
|
|
|
|
|
DeviceType: this.cs.getDeviceType(),
|
|
|
|
|
DeviceToken: deviceToken
|
|
|
|
|
DeviceType: this.cs.getDeviceType(),
|
|
|
|
|
DeviceToken: deviceToken
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
this.getLoginInfo(requestGetLoginInfo, () => {}, this.ts.trPK('general', 'ok')).subscribe(res => {
|
|
|
|
|
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 {}
|
|
|
|
|
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 { }
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -727,6 +736,27 @@ export class AuthenticationService {
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
checkAds(request, onError, errorLabel) {
|
|
|
|
|
request = this.authenticateRequest(request);
|
|
|
|
|
request.EmployeeNumber = request.UserName;
|
|
|
|
|
return this.con.post(AuthenticationService.getITGPageNotification, request, onError, errorLabel);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
adsDetails(request, onError, errorLabel) {
|
|
|
|
|
request = this.authenticateRequest(request);
|
|
|
|
|
request.EmployeeNumber = request.UserName;
|
|
|
|
|
return this.con.post(AuthenticationService.getITGPageNotificationDetails, request, onError, errorLabel);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
saveAdsStatus(request, onError, errorLabel) {
|
|
|
|
|
request = this.authenticateRequest(request);
|
|
|
|
|
request.EmployeeNumber = request.UserName;
|
|
|
|
|
return this.con.post(AuthenticationService.saveSurveyAds, request, onError, errorLabel);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//**************************//
|
|
|
|
|
|
|
|
|
|
public sendActivationCodeByType(
|
|
|
|
|
@ -744,4 +774,5 @@ export class AuthenticationService {
|
|
|
|
|
onError,
|
|
|
|
|
errorLabel
|
|
|
|
|
);
|
|
|
|
|
}}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|