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

Loading…
Cancel
Save