update home

production
Sultan Khan 7 years ago
parent eea8947dc7
commit 947fbda4da

@ -32,44 +32,43 @@ import { ForgetPassword } from 'src/app/authentication/models/forget.password';
providedIn: "root"
})
export class AuthenticationService {
public static MOBILE_USER = 102;
/* login methods */
public static loginURL =
"Services/Authentication.svc/REST/CheckPatientAuthentication";
public static checkUserAuthURL =
"Services/Authentication.svc/REST/CheckPatientAuthentication";
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 login = 'Services/ERP.svc/REST/MemberLogin';
public static activationCodeURL =
"Services/Authentication.svc/REST/CheckActivationCode";
public static getLoginInfoURL =
"Services/Authentication.svc/REST/GetMobileLoginInfo";
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 smsCheck='Services/ERP.svc/REST/CheckActivationCode';
public static smsCheckForget='Services/ERP.svc/REST/CheckPublicActivationCode';
public static smsSendCode='Services/ERP.svc/REST/SendPublicActivationCode';
/* 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 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 LOGIN_EVENT = "user-login-event";
public static FAMILY_LOGIN_EVENT = "family-login-event";
public static AUTHENTICATED_USER_KEY = "save-authenticated-user";
/*user checking methods */
public static userChecking = 'Services/ERP.svc/REST/Get_BasicUserInformation';
public static changePasswordForget ='Services/ERP.svc/REST/ChangePassword_Forget';
public static LOGIN_EVENT = 'user-login-event';
public static FAMILY_LOGIN_EVENT = 'family-login-event';
public static AUTHENTICATED_USER_KEY = 'save-authenticated-user';
// private static user: AuthenticatedUser;
constructor(
@ -79,13 +78,13 @@ export class AuthenticationService {
public nativeStorage: NativeStorage,
public localNotifications: UserLocalNotificationService,
private events: Events
) {}
) { }
public authenticateRequest(request: Request, automaticLogin = true): Request {
this.setPublicFields(request);
const user = this.getAuthenticatedUser();
if (user) {
/*user with eye prescriptions*/
request.P_SESSION_ID = user.P_SESSION_ID;
request.MobileNumber = user.EMPLOYEE_MOBILE_NUMBER;
request.LogInTokenID = user.LogInTokenID;
@ -118,7 +117,6 @@ export class AuthenticationService {
//request.isDentalAllowedBackend = false;
return request;
}
public authenticateAndSetPersonalInformation(
request: EmailRequest,
examinationInfo?: any
@ -164,39 +162,34 @@ export class AuthenticationService {
return request;
}
public getAuthenticatedRequest(login = true): Request {
const request = new Request();
this.authenticateRequest(request, login);
return request;
}
public getPublicRequest(): Request {
const request = new Request();
this.setPublicFields(request);
return request;
}
public login(
request: LoginRequest,
onError: any,
errorLabel: string
): Observable<Response> {
request.PatientID = 0;
request.TokenID = "";
request.isDentalAllowedBackend = false;
request.isRegister = false;
return this.con.post(
AuthenticationService.loginURL,
request,
onError,
errorLabel
);
public login(request: LoginRequest, onError: any, errorLabel: string): Observable<Response> {
this.setPublicFields(request);
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
@ -229,6 +222,7 @@ export class AuthenticationService {
});
}
public resetAuthenticatedUser(user: AuthenticatedUser) {
AuthenticationService.user = user;
AuthenticationService.requireRelogin = false;
@ -260,7 +254,6 @@ export class AuthenticationService {
});
});
}
public setDeviceToken(token: string) {
const user = this.getAuthenticatedUser();
if (user) {
@ -355,7 +348,6 @@ export class AuthenticationService {
}
});
}
/**
* signout
*clear user session and storage information
@ -431,46 +423,35 @@ export class AuthenticationService {
return AuthenticationService.user;
}
public checkUserAuthentication(
request: CheckUserAuthenticationRequest,
onError: any,
errorLabel: string
): Observable<CheckUserAuthenticationResponse> {
public checkUserAuthentication(request: CheckUserAuthenticationRequest, onError: any, errorLabel: string)
: Observable<CheckUserAuthenticationResponse> {
this.setPublicFields(request);
return this.con.post(
AuthenticationService.login,
request,
onError,
errorLabel
);
return this.con.post(AuthenticationService.userChecking, request, onError, errorLabel);
}
public checkActivationCode(
request: CheckActivationCodeRequest,
onError: any,
errorLabel: string
): Observable<CheckActivationCodeResponse> {
public checkActivationCode(request: CheckActivationCodeRequest, onError: any, errorLabel: string)
: Observable<CheckActivationCodeResponse> {
this.setPublicFields(request);
return this.con.post(
AuthenticationService.activationCodeURL,
request,
onError,
errorLabel
);
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 sendPublicSMS(request: SMSCheckRequest, onError: any, errorLabel: string)
: Observable<CheckUserAuthenticationResponse> {
this.setPublicFields(request);
return this.con.post(AuthenticationService.smsSendCode, request, onError, errorLabel);
}
/*
@ -482,74 +463,52 @@ export class AuthenticationService {
client side:
id no , mobile no , zip code
*/
public sendSmsForPatientRegisteration(
request: CheckPatientRegisterationRequest,
onError: any,
errorLabel: string
): Observable<CheckUserAuthenticationResponse> {
public sendSmsForPatientRegisteration(request: CheckPatientRegisterationRequest, onError: any, errorLabel: string)
: Observable<CheckUserAuthenticationResponse> {
this.setPublicFields(request);
request.TokenID = "";
request.TokenID = '';
request.isRegister = false;
return this.con.post(
AuthenticationService.sendSmsForRegisterURL,
request,
onError,
errorLabel
);
return this.con.post(AuthenticationService.sendSmsForRegisterURL, request, onError, errorLabel);
}
public checkRegisterationActivationCode(
request: CheckRegisterationCodeRequest,
onError: any,
errorLabel: string
): Observable<Response> {
public checkRegisterationActivationCode(request: CheckRegisterationCodeRequest, onError: any, errorLabel: string)
: Observable<Response> {
this.setPublicFields(request);
return this.con.post(
AuthenticationService.activationCodeURL,
request,
onError,
errorLabel
);
return this.con.post(AuthenticationService.activationCodeURL, request, onError, errorLabel);
}
public sendSMSForForgotFileNumber(
request: CheckUserAuthenticationRequest,
onError: any,
errorLabel: string
): Observable<CheckUserAuthenticationResponse> {
public sendForgetPassword(request: ForgetPassword, onError: any, errorLabel: string)
: Observable<CheckUserAuthenticationResponse> {
this.setPublicFields(request);
request.TokenID = "";
// request.PatientIdentificationID = '';
// request.PatientID = 0;
return this.con.post(AuthenticationService.smsSendCode, 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 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
);
return this.con.post(AuthenticationService.sendSMSForgotFileNoURL, request, onError, errorLabel);
}
public forgotFileIdActivation(
request: CheckActivationCodeRequest,
onError: any,
errorLabel: string
): Observable<ForgotFileIDResponse> {
public forgotFileIdActivation(request: CheckActivationCodeRequest, onError: any, errorLabel: string)
: Observable<ForgotFileIDResponse> {
this.setPublicFields(request);
request.TokenID = "";
request.PatientIdentificationID = "";
// request.PatientID = 0;
request.TokenID = '';
request.SearchType = 2;
request.isRegister = false;
return this.con.post(
AuthenticationService.forgotFileIDURL,
request,
onError,
errorLabel
);
return this.con.post(AuthenticationService.forgotFileIDURL, request, onError, errorLabel);
}
public isSAUDIIDValid(id: string): boolean {
if (!id) {
return false;

Loading…
Cancel
Save