From 1d79849787ba69b9afb7dda35bbc3ee069aeeeac Mon Sep 17 00:00:00 2001 From: ansariakhtar Date: Wed, 26 Jun 2019 16:29:15 +0300 Subject: [PATCH 1/3] forgot password completed --- .../authentication/authentication.module.ts | 8 +- .../check-user/check-user.component.html | 33 +++++++ .../check-user/check-user.component.scss | 7 ++ .../check-user/check-user.component.spec.ts | 27 +++++ .../check-user/check-user.component.ts | 98 +++++++++++++++++++ .../forgot/forgot.component.html | 27 +++-- .../authentication/forgot/forgot.component.ts | 82 ++++++---------- .../authentication/login/login.component.ts | 5 +- .../authentication/models/forget.password.ts | 7 ++ .../src/app/authentication/models/password.ts | 10 ++ .../authentication/sms-page/sms-page.page.ts | 25 ++++- .../authentication/authentication.service.ts | 39 ++++++-- .../authentication/models/basic.info.ts | 7 ++ .../models/check-user-auth.response.ts | 10 ++ .../authentication/models/login.request.ts | 5 + .../authentication/models/member.list.ts | 9 ++ .../services/common/common.service.ts | 8 +- Mohem/src/assets/localization/i18n.json | 14 +++ 18 files changed, 348 insertions(+), 73 deletions(-) create mode 100644 Mohem/src/app/authentication/check-user/check-user.component.html create mode 100644 Mohem/src/app/authentication/check-user/check-user.component.scss create mode 100644 Mohem/src/app/authentication/check-user/check-user.component.spec.ts create mode 100644 Mohem/src/app/authentication/check-user/check-user.component.ts create mode 100644 Mohem/src/app/authentication/models/forget.password.ts create mode 100644 Mohem/src/app/authentication/models/password.ts create mode 100644 Mohem/src/app/hmg-common/services/authentication/models/basic.info.ts create mode 100644 Mohem/src/app/hmg-common/services/authentication/models/member.list.ts diff --git a/Mohem/src/app/authentication/authentication.module.ts b/Mohem/src/app/authentication/authentication.module.ts index c1551cb3..80456df0 100644 --- a/Mohem/src/app/authentication/authentication.module.ts +++ b/Mohem/src/app/authentication/authentication.module.ts @@ -18,6 +18,7 @@ import { MobileNumberModule } from 'src/app/hmg-common/ui/mobile-number/mobile- import { SmsdialogPageModule } from 'src/app/hmg-common/ui/smsdialog/smsdialog.module'; import { SmsPageModule } from 'src/app/hmg-common/ui/sms/sms.module'; import { SmsPagePage } from './sms-page/sms-page.page'; +import { CheckUserComponent } from './check-user/check-user.component'; @@ -41,6 +42,10 @@ const routes: Routes = [ { path: 'smspage', component: SmsPagePage + }, + { + path: 'checkuser', + component: CheckUserComponent } ] } @@ -65,7 +70,8 @@ const routes: Routes = [ LoginComponent, ForgotComponent, AgreementComponent, - SmsPagePage + SmsPagePage, + CheckUserComponent ], providers:[ FingerprintAIO, diff --git a/Mohem/src/app/authentication/check-user/check-user.component.html b/Mohem/src/app/authentication/check-user/check-user.component.html new file mode 100644 index 00000000..40ce8b47 --- /dev/null +++ b/Mohem/src/app/authentication/check-user/check-user.component.html @@ -0,0 +1,33 @@ + + + + + + {{'login,forgot-password' | translate}} + + + + + + + + + + + + {{ts.trPK('login','username')}} + + + + + + + + + + + +
+ {{ts.trPK('login','changepassword')}} +
+
\ No newline at end of file diff --git a/Mohem/src/app/authentication/check-user/check-user.component.scss b/Mohem/src/app/authentication/check-user/check-user.component.scss new file mode 100644 index 00000000..4357e11d --- /dev/null +++ b/Mohem/src/app/authentication/check-user/check-user.component.scss @@ -0,0 +1,7 @@ +.header-toolbar{ + --background: linear-gradient(45deg, #3ac1f1 0%, #19a163 36%, #19a163 59%, #1a586d 100%); +} + +.btnBack{ + background: transparent; +} \ No newline at end of file diff --git a/Mohem/src/app/authentication/check-user/check-user.component.spec.ts b/Mohem/src/app/authentication/check-user/check-user.component.spec.ts new file mode 100644 index 00000000..b1d86516 --- /dev/null +++ b/Mohem/src/app/authentication/check-user/check-user.component.spec.ts @@ -0,0 +1,27 @@ +import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core'; +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; + +import { CheckUserComponent } from './check-user.component'; + +describe('CheckUserComponent', () => { + let component: CheckUserComponent; + let fixture: ComponentFixture; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [ CheckUserComponent ], + schemas: [CUSTOM_ELEMENTS_SCHEMA], + }) + .compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(CheckUserComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/Mohem/src/app/authentication/check-user/check-user.component.ts b/Mohem/src/app/authentication/check-user/check-user.component.ts new file mode 100644 index 00000000..b510b256 --- /dev/null +++ b/Mohem/src/app/authentication/check-user/check-user.component.ts @@ -0,0 +1,98 @@ +import { Component, OnInit, ViewChild, ChangeDetectorRef, OnDestroy } from '@angular/core'; +import { CommonService } from 'src/app/hmg-common/services/common/common.service'; +import { AuthenticationService } from 'src/app/hmg-common/services/authentication/authentication.service'; +import { Router } from '@angular/router'; +import { AlertController } from '@ionic/angular'; +import { TranslatorService } from 'src/app/hmg-common/services/translator/translator.service'; +import { CheckUserAuthenticationRequest } from 'src/app/hmg-common/services/authentication/models/check-user-auth.request'; +import { CheckUserAuthenticationResponse } from 'src/app/hmg-common/services/authentication/models/check-user-auth.response'; +import { CheckActivationCodeRequest } from 'src/app/hmg-common/services/authentication/models/check-activation-code.request'; +import { SmsReaderService } from 'src/app/hmg-common/services/sms/sms-reader.service'; +import { ForgotFileIDResponse } from '../../hmg-common/services/authentication/models/forgot-File-ID.response'; +import { InternationalMobileComponent } from 'src/app/hmg-common/ui/mobile-number/international-mobile/international-mobile.component'; +import { CountryCode } from 'src/app/hmg-common/ui/mobile-number/international-mobile/models/country-code.model'; +import { LoginRequest } from 'src/app/hmg-common/services/authentication/models/login.request'; +import { SharedDataService } from 'src/app/hmg-common/services/shared-data-service/shared-data.service'; +import { Password } from '../models/password'; +import { LoginModel } from '../models/LoginModel'; + +@Component({ + selector: 'app-check-user', + templateUrl: './check-user.component.html', + styleUrls: ['./check-user.component.scss'], +}) +export class CheckUserComponent implements OnInit,OnDestroy { + public P_USER_NAME : string; + private loginData = new LoginModel(); + + @ViewChild(InternationalMobileComponent) internationlMobile: InternationalMobileComponent; + constructor(public cs: CommonService, + public authService: AuthenticationService, + public router: Router, + public alertController: AlertController, + public ts: TranslatorService, + public smsService: SmsReaderService, + public sharedData: SharedDataService, + public changeDetector: ChangeDetectorRef) { } + + ngOnInit() {} + + ngOnDestroy(): void { + this.smsService.stopSMSMonitoring(); + } + + public onForgot() { + this.sendSMSForForgotPassword(); + } + + public userCheck() + { + this.cs.startLoading(); + const request = new CheckUserAuthenticationRequest(); + request.P_USER_NAME = this.P_USER_NAME; + this.authService.checkUserAuthentication( + request, + () => { + //this.sendSMSForForgotPassword(); + }, this.ts.trPK('general', 'ok')).subscribe((result: CheckUserAuthenticationResponse) => { + if (this.cs.validResponse(result)) { + this.checkUserResult = result; + this.cs.stopLoading(); + this.sendSMSForForgotPassword(); + + // if (result.isSMSSent) { + // this.startReceivingSMS(); + // this.presentSMSPasswordDialog(); + // } + } + }); + } + + private checkUserResult: CheckUserAuthenticationResponse; + + private sendSMSForForgotPassword() { + this.cs.startLoading(); + let changePwdObj= new LoginRequest(); + changePwdObj.MobileNumber= this.checkUserResult.BasicMemberInformation.P_MOBILE_NUMBER; + changePwdObj.P_USER_NAME=this.P_USER_NAME; + changePwdObj.P_MOBILE_NUMBER=this.checkUserResult.BasicMemberInformation.P_MOBILE_NUMBER; + + this.authService.sendPublicSMS( + changePwdObj, + () => { + this.sendSMSForForgotPassword(); + }, this.ts.trPK('general', 'ok')).subscribe((result: CheckUserAuthenticationResponse) => { + if (this.cs.validResponse(result)) { + this.checkUserResult = result; + console.log("2"); + console.log(result); + this.loginData.LogInTokenID = result.LogInTokenID; + this.loginData.P_USER_NAME = this.P_USER_NAME; + this.sharedData.setSharedData(this.loginData, "logindata"); + this.sharedData.setSharedData(true,Password.IS_FORGET_PSW); + this.cs.stopLoading(); + this.cs.openSMSPage(); + }}); + } +} + diff --git a/Mohem/src/app/authentication/forgot/forgot.component.html b/Mohem/src/app/authentication/forgot/forgot.component.html index 1bc60365..9e46cdb7 100644 --- a/Mohem/src/app/authentication/forgot/forgot.component.html +++ b/Mohem/src/app/authentication/forgot/forgot.component.html @@ -12,14 +12,21 @@ - - - - {{ts.trPK('login','username')}} - - - - + + + {{'changePassword,newPassword' | translate}} + + + + + + + {{'changePassword,confirmPassword' | translate}} + + + @@ -28,6 +35,6 @@
- {{ts.trPK('login','changepassword')}} -
+ {{ts.trPK('login','changepassword')}} +
\ No newline at end of file diff --git a/Mohem/src/app/authentication/forgot/forgot.component.ts b/Mohem/src/app/authentication/forgot/forgot.component.ts index 949f40a2..3cbe099a 100644 --- a/Mohem/src/app/authentication/forgot/forgot.component.ts +++ b/Mohem/src/app/authentication/forgot/forgot.component.ts @@ -11,7 +11,9 @@ import { SmsReaderService } from 'src/app/hmg-common/services/sms/sms-reader.ser import { ForgotFileIDResponse } from '../../hmg-common/services/authentication/models/forgot-File-ID.response'; import { InternationalMobileComponent } from 'src/app/hmg-common/ui/mobile-number/international-mobile/international-mobile.component'; import { CountryCode } from 'src/app/hmg-common/ui/mobile-number/international-mobile/models/country-code.model'; - +import { ForgetPassword } from '../models/forget.password'; +import { LoginModel } from '../models/LoginModel'; +import { SharedDataService } from 'src/app/hmg-common/services/shared-data-service/shared-data.service'; @Component({ selector: 'app-forgot', @@ -20,7 +22,10 @@ import { CountryCode } from 'src/app/hmg-common/ui/mobile-number/international-m }) export class ForgotComponent implements OnInit,OnDestroy { - public countryCode: CountryCode; + private loginData = new LoginModel(); + public P_NEW_PASSWORD: string; + public P_Confirm_NEW_PASSWORD : string; + public P_USER_NAME : string; @ViewChild(InternationalMobileComponent) internationlMobile: InternationalMobileComponent; constructor( public cs: CommonService, @@ -29,7 +34,8 @@ export class ForgotComponent implements OnInit,OnDestroy { public alertController: AlertController, public ts: TranslatorService, public smsService: SmsReaderService, - public changeDetector: ChangeDetectorRef + public changeDetector: ChangeDetectorRef, + public sharedData: SharedDataService ) { } @@ -39,77 +45,49 @@ export class ForgotComponent implements OnInit,OnDestroy { ngOnDestroy(): void { this.smsService.stopSMSMonitoring(); } + public onForgot() { this.sendSMSForForgotPassword(); } - - public countryCodeChanged(countryCode: CountryCode) { - this.countryCode = countryCode; - } - - public isValidForm() { - return (this.countryCode && this.countryCode.isValid); - } - - - private checkUserResult: CheckUserAuthenticationResponse; private sendSMSForForgotPassword() { - const request = new CheckUserAuthenticationRequest(); + const request = new ForgetPassword(); //request.PatientMobileNumber = this.countryCode.number; //request.ZipCode = CountryCode.localCode(this.countryCode.code); - - this.authService.sendSMSForForgotFileNumber( + this.authService.sendForgetPassword( request, () => { this.sendSMSForForgotPassword(); }, this.ts.trPK('general', 'ok')).subscribe((result: CheckUserAuthenticationResponse) => { if (this.cs.validResponse(result)) { this.checkUserResult = result; - if (result.isSMSSent) { - this.startReceivingSMS(); - this.presentSMSPasswordDialog(); - } } }); } - - private startReceivingSMS() { - this.smsService.startSMSMonitoring((code) => { - this.cs.dismissSMSDialog().subscribe(cleared => { - this.checkActivationCode(code); - }); - }); - } - public presentSMSPasswordDialog() { - this.cs.presentSMSPasswordDialog( - (code: string) => { - this.checkActivationCode(code); - }); - } - - private checkActivationCode(readedCode?) { - const request = new CheckActivationCodeRequest(); - request.LogInTokenID = this.checkUserResult.LogInTokenID; - request.PatientOutSA = this.checkUserResult.PatientOutSA ? 1 : 0; - request.PatientMobileNumber = this.countryCode.number; - request.ZipCode = CountryCode.localCode(this.countryCode.code); - request.activationCode = readedCode; - - this.authService.forgotFileIdActivation(request, + public forgotpassword(){ + const data = this.sharedData.getSharedData("logindata", false); + this.loginData.P_USER_NAME = this.P_USER_NAME; + let request:ForgetPassword = new ForgetPassword(); + request.P_Confirm_NEW_PASSWORD=this.P_NEW_PASSWORD; + request.P_NEW_PASSWORD=this.P_Confirm_NEW_PASSWORD; + request.P_USER_NAME = data.P_USER_NAME; + //console.log(request); + //request.P_USER_NAME = this.userName.P_USER_NAME; + this.authService.submitForgetPassword( + request, () => { - this.presentSMSPasswordDialog(); - }, this.ts.trPK('general', 'retry')).subscribe((result: ForgotFileIDResponse) => { + //this.sendSMSForForgotPassword(); + }, this.ts.trPK('general', 'ok')).subscribe((result: CheckUserAuthenticationResponse) => { if (this.cs.validResponse(result)) { - this.smsService.stopSMSMonitoring(); - this.cs.presentAlert(result.ReturnMessage); + this.checkUserResult = result; + console.log(result); + this.cs.toastPK("changePassword","passwordchanged"); + this.cs.openLogin(); } }); - + } - - } diff --git a/Mohem/src/app/authentication/login/login.component.ts b/Mohem/src/app/authentication/login/login.component.ts index d5e5bfde..09cb7398 100644 --- a/Mohem/src/app/authentication/login/login.component.ts +++ b/Mohem/src/app/authentication/login/login.component.ts @@ -17,6 +17,7 @@ import { Device } from '@ionic-native/device/ngx'; import { SplashScreen } from '@ionic-native/splash-screen/ngx'; import { SharedDataService } from 'src/app/hmg-common/services/shared-data-service/shared-data.service'; import { LoginModel } from '../models/LoginModel'; +import { LoginRequest } from 'src/app/hmg-common/services/authentication/models/login.request'; @Component({ selector: 'login', @@ -356,12 +357,12 @@ export class LoginComponent implements OnInit, OnDestroy { } private checkUserAuthentication() { - const request = new CheckUserAuthenticationRequest(); + const request = new LoginRequest(); request.P_USER_NAME = this.username; request.P_LANGUAGE = this.language; request.P_PASSWORD = this.password; console.log(request); - this.authService.checkUserAuthentication( + this.authService.login( request, () => { }, this.ts.trPK('general', 'ok')).subscribe((result: CheckUserAuthenticationResponse) => { diff --git a/Mohem/src/app/authentication/models/forget.password.ts b/Mohem/src/app/authentication/models/forget.password.ts new file mode 100644 index 00000000..b6cda129 --- /dev/null +++ b/Mohem/src/app/authentication/models/forget.password.ts @@ -0,0 +1,7 @@ +import { Request } from 'src/app/hmg-common/services/models/request'; +export class ForgetPassword extends Request { + public static IS_FORGET_PSW:string="is_forget_password"; + public P_NEW_PASSWORD: string; + public P_Confirm_NEW_PASSWORD:string; + public P_USER_NAME : string; +} diff --git a/Mohem/src/app/authentication/models/password.ts b/Mohem/src/app/authentication/models/password.ts new file mode 100644 index 00000000..4a160292 --- /dev/null +++ b/Mohem/src/app/authentication/models/password.ts @@ -0,0 +1,10 @@ +import { Request } from 'src/app/hmg-common/services/models/request'; + + +export class Password extends Request { + public static IS_FORGET_PSW:string="is_forget_password"; + public IS_FORGET_PWD:boolean; + public P_NEW_PASSWORD: string; + public P_OLD_PASSWORD:string; + public P_Confirm_NEW_PASSWORD:string; +} \ No newline at end of file diff --git a/Mohem/src/app/authentication/sms-page/sms-page.page.ts b/Mohem/src/app/authentication/sms-page/sms-page.page.ts index 7a07a8aa..b28e7db6 100644 --- a/Mohem/src/app/authentication/sms-page/sms-page.page.ts +++ b/Mohem/src/app/authentication/sms-page/sms-page.page.ts @@ -8,6 +8,7 @@ import { SMSCheckRequest } from 'src/app/hmg-common/services/authentication/mode import { LoginModel } from '../models/LoginModel'; import { AuthenticationService } from 'src/app/hmg-common/services/authentication/authentication.service'; import { SMSCheckResponse } from 'src/app/hmg-common/services/authentication/models/smscheck.response'; +import { Password } from '../models/password'; @Component({ @@ -44,6 +45,7 @@ export class SmsPagePage implements OnInit { this.count = 0; this.initTimer(); this.startTimer(); + this.isForgetPwd = this.sharedData.getSharedData(Password.IS_FORGET_PSW) || false; } @@ -126,7 +128,7 @@ export class SmsPagePage implements OnInit { request.activationCode =this.activationCode; //request.P_USER_NAME=this.userName, //request.MobileNumber=this.member.MemberLoginList.P_MOBILE_NUMBER - + console.log(data.LogInTokenID); this.authService.checkSMS( request, () => { @@ -143,7 +145,28 @@ export class SmsPagePage implements OnInit { public checkForgetPwdSMS() { + const data = this.sharedData.getSharedData("logindata", false); + const request = new SMSCheckRequest(); + + request.LogInTokenID= data.LogInTokenID, + request.activationCode =this.activationCode; + //request.P_USER_NAME=this.userName, + //request.MobileNumber=this.member.MemberLoginList.P_MOBILE_NUMBER + console.log(data.LogInTokenID); + this.authService.checkForgetSMS( + request, + () => { + }, this.translate.trPK('general', 'ok')).subscribe((result: SMSCheckResponse) => { + console.log(result); + if (this.common.validResponse(result)) { + console.log(result); + + //this.loginData.LogInTokenID = result.LogInTokenID; + //this.sharedData.setSharedData(this.loginData, "logindata"); + this.common.openForgotPassword(); + } + }); } } diff --git a/Mohem/src/app/hmg-common/services/authentication/authentication.service.ts b/Mohem/src/app/hmg-common/services/authentication/authentication.service.ts index f71a6117..292297ef 100644 --- a/Mohem/src/app/hmg-common/services/authentication/authentication.service.ts +++ b/Mohem/src/app/hmg-common/services/authentication/authentication.service.ts @@ -26,6 +26,7 @@ import { Events } from '@ionic/angular'; import { InternationalMobileComponent } from '../../ui/mobile-number/international-mobile/international-mobile.component'; import { SMSCheckRequest } from './models/smscheck.request'; import { SMSCheckResponse } from './models/smscheck.response'; +import { ForgetPassword } from 'src/app/authentication/models/forget.password'; @Injectable({ providedIn: 'root' @@ -58,6 +59,10 @@ export class AuthenticationService { public static forgotFileIDURL = 'Services/Authentication.svc/REST/CheckActivationCodeForSendFileNo'; public static user: AuthenticatedUser; + /*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'; @@ -156,11 +161,8 @@ export class AuthenticationService { public login(request: LoginRequest, onError: any, errorLabel: string): Observable { - request.PatientID = 0; - request.TokenID = ''; - request.isDentalAllowedBackend = false; - request.isRegister = false; - return this.con.post(AuthenticationService.loginURL, request, onError, errorLabel); + this.setPublicFields(request); + return this.con.post(AuthenticationService.login, request, onError, errorLabel); } @@ -430,7 +432,7 @@ export class AuthenticationService { public checkUserAuthentication(request: CheckUserAuthenticationRequest, onError: any, errorLabel: string) : Observable { 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) @@ -445,6 +447,18 @@ export class AuthenticationService { return this.con.post(AuthenticationService.smsCheck, request, onError, errorLabel); } + public checkForgetSMS(request: SMSCheckRequest, onError: any, errorLabel: string) + : Observable { + this.setPublicFields(request); + return this.con.post(AuthenticationService.smsCheckForget, request, onError, errorLabel); + } + + public sendPublicSMS(request: SMSCheckRequest, onError: any, errorLabel: string) + : Observable { + this.setPublicFields(request); + return this.con.post(AuthenticationService.smsSendCode, request, onError, errorLabel); + } + /* client side: id no , mobile no , zip code @@ -476,6 +490,19 @@ export class AuthenticationService { return this.con.post(AuthenticationService.activationCodeURL, request, onError, errorLabel); } + public sendForgetPassword(request: ForgetPassword, onError: any, errorLabel: string) + : Observable { + this.setPublicFields(request); + return this.con.post(AuthenticationService.smsSendCode, request, onError, errorLabel); + } + + public submitForgetPassword(request: ForgetPassword, onError: any, errorLabel: string) + : Observable { + this.setPublicFields(request); + return this.con.post(AuthenticationService.changePasswordForget, request, onError, errorLabel); + } + + public sendSMSForForgotFileNumber(request: CheckUserAuthenticationRequest, onError: any, errorLabel: string) : Observable { this.setPublicFields(request); diff --git a/Mohem/src/app/hmg-common/services/authentication/models/basic.info.ts b/Mohem/src/app/hmg-common/services/authentication/models/basic.info.ts new file mode 100644 index 00000000..fc4a19a1 --- /dev/null +++ b/Mohem/src/app/hmg-common/services/authentication/models/basic.info.ts @@ -0,0 +1,7 @@ + +export class BasicInfo extends Request{ + public P_EMAIL_ADDRESS:string; + public P_MOBILE_NUMBER: string; + public P_RETURN_MSG: string; + public P_RETURN_STATUS: string; +} diff --git a/Mohem/src/app/hmg-common/services/authentication/models/check-user-auth.response.ts b/Mohem/src/app/hmg-common/services/authentication/models/check-user-auth.response.ts index e7e942f0..cc33d22d 100644 --- a/Mohem/src/app/hmg-common/services/authentication/models/check-user-auth.response.ts +++ b/Mohem/src/app/hmg-common/services/authentication/models/check-user-auth.response.ts @@ -1,4 +1,6 @@ import { Response } from '../../models/response'; +import { BasicInfo } from './basic.info'; +import { MemberList } from './member.list'; export class CheckUserAuthenticationResponse extends Response { PatientHasFile: boolean; @@ -10,4 +12,12 @@ export class CheckUserAuthenticationResponse extends Response { hasFile: boolean; isSMSSent: boolean; LogInTokenID: string; + P_EMAIL_ADDRESS : string; + P_MOBILE_NUMBER : string; + P_RETURN_MSG : string; + P_RETURN_STATUS : string; + public IsPasswordExpired: boolean; + //public P_SESSION_ID:string; + public MemberLoginList: MemberList ; + public BasicMemberInformation: BasicInfo; } diff --git a/Mohem/src/app/hmg-common/services/authentication/models/login.request.ts b/Mohem/src/app/hmg-common/services/authentication/models/login.request.ts index 5d6b3511..cb1cdbf5 100644 --- a/Mohem/src/app/hmg-common/services/authentication/models/login.request.ts +++ b/Mohem/src/app/hmg-common/services/authentication/models/login.request.ts @@ -7,6 +7,11 @@ export class LoginRequest extends Request { SearchType: number; // 1 for iqama 2 for file number TokenID: string; // "" ZipCode: string; // "966" + MobileNumber: string; + P_USER_NAME : string; + P_MOBILE_NUMBER : string; + P_PASSWORD : string; + P_LANGUAGE : string; // isDentalAllowedBackend: false isRegister: boolean; // false } diff --git a/Mohem/src/app/hmg-common/services/authentication/models/member.list.ts b/Mohem/src/app/hmg-common/services/authentication/models/member.list.ts new file mode 100644 index 00000000..e74b563f --- /dev/null +++ b/Mohem/src/app/hmg-common/services/authentication/models/member.list.ts @@ -0,0 +1,9 @@ +export class MemberList { + public P_EMAIL_ADDRESS:string; + public P_INVALID_LOGIN_MSG: string; + public P_MOBILE_NUMBER: string; + public P_PASSOWRD_EXPIRED: string; + public P_RETURN_MSG: string; + public P_RETURN_STATUS: string; + public P_SESSION_ID: number; +} \ No newline at end of file diff --git a/Mohem/src/app/hmg-common/services/common/common.service.ts b/Mohem/src/app/hmg-common/services/common/common.service.ts index e13d1fad..ac967af1 100644 --- a/Mohem/src/app/hmg-common/services/common/common.service.ts +++ b/Mohem/src/app/hmg-common/services/common/common.service.ts @@ -891,6 +891,9 @@ export class CommonService { public openHome() { this.alternateNavigate(CommonService.HOME_URL, "home-open", true); } + public openForgotPassword() { + this.nav.navigateForward(["/authentication/forgot"]); + } public reload(url: string, from: string) { console.log("force reload called from:" + from); @@ -930,9 +933,12 @@ export class CommonService { } } + public openLogin() { + this.nav.navigateRoot(["/authentication/login"]); + } public openUserForgot() { - this.nav.navigateForward(["/authentication/forgot"]); + this.nav.navigateForward(["/authentication/checkuser"]); } public openSMSPage() { this.nav.navigateForward(["/authentication/smspage"]); diff --git a/Mohem/src/assets/localization/i18n.json b/Mohem/src/assets/localization/i18n.json index 3467ca8a..4f926ef5 100644 --- a/Mohem/src/assets/localization/i18n.json +++ b/Mohem/src/assets/localization/i18n.json @@ -90,6 +90,20 @@ "ar":"تحقق مرة واحدة كلمة المرور" } }, +"changePassword":{ + "newPassword":{ + "en":"New Password", + "ar":"كلمة المرور الجديدة" + }, + "confirmPassword":{ + "en":"Confirm Password", + "ar":"تأكيد كلمة المرور" + }, + "passwordchanged":{ + "en":"Your password changed successfully", + "ar":"تم تغيير كلمة المرور الخاصة بك بنجاح" + } +}, "verificationcode": { "verificationcode":{ From b967536b265cd3e7305ce6dc9f409bec88454e5b Mon Sep 17 00:00:00 2001 From: Sultan Khan Date: Wed, 26 Jun 2019 17:04:03 +0300 Subject: [PATCH 2/3] update home --- Mohem/src/app/app.component.html | 4 +- Mohem/src/app/app.component.scss | 267 ++-- Mohem/src/app/app.component.ts | 2 +- .../authentication/forgot/forgot.component.ts | 2 +- .../authentication/login/login.component.ts | 9 +- Mohem/src/app/hmg-common/hmg-common.module.ts | 5 +- .../authentication/authentication.service.ts | 1177 +++++++++-------- .../models/authenticated-user.ts | 142 +- .../models/check-activation-code.response.ts | 5 + .../authentication/models/smscheck.request.ts | 2 +- .../models/smscheck.response.ts | 9 +- .../services/geofencing/geofencing.service.ts | 4 +- .../services/menu/menuservice.service.spec.ts | 12 + .../services/menu/menuservice.service.ts | 50 + .../services/menu/models/list.menu.ts | 7 + .../menu/models/menu-entries.request.ts | 6 + .../services/menu/models/menu-response.ts | 9 + .../services/menu/models/menu.entry.ts | 13 + .../services/menu/models/request.ts | 18 + .../app/hmg-common/services/models/request.ts | 13 +- .../services/translator/translator.service.ts | 2 +- Mohem/src/app/home/home.page.html | 4 +- Mohem/src/app/home/home.page.ts | 71 +- Mohem/src/theme/styles.scss | 8 +- 24 files changed, 1068 insertions(+), 773 deletions(-) create mode 100644 Mohem/src/app/hmg-common/services/menu/menuservice.service.spec.ts create mode 100644 Mohem/src/app/hmg-common/services/menu/menuservice.service.ts create mode 100644 Mohem/src/app/hmg-common/services/menu/models/list.menu.ts create mode 100644 Mohem/src/app/hmg-common/services/menu/models/menu-entries.request.ts create mode 100644 Mohem/src/app/hmg-common/services/menu/models/menu-response.ts create mode 100644 Mohem/src/app/hmg-common/services/menu/models/menu.entry.ts create mode 100644 Mohem/src/app/hmg-common/services/menu/models/request.ts diff --git a/Mohem/src/app/app.component.html b/Mohem/src/app/app.component.html index 97f8ceb3..edf5dc1b 100644 --- a/Mohem/src/app/app.component.html +++ b/Mohem/src/app/app.component.html @@ -12,7 +12,7 @@ - +
-

{{"home.dashboard" | translate}}

+

{{"userData.dashboard" | translate}}

diff --git a/Mohem/src/app/home/home.page.ts b/Mohem/src/app/home/home.page.ts index 361f0ead..fcd61833 100644 --- a/Mohem/src/app/home/home.page.ts +++ b/Mohem/src/app/home/home.page.ts @@ -1,46 +1,59 @@ -import { Component, OnInit } from '@angular/core'; -import { TranslatorService } from 'src/app/hmg-common/services/translator/translator.service'; -import { MenuController } from '@ionic/angular'; +import { Component, OnInit } from "@angular/core"; +import { TranslatorService } from "src/app/hmg-common/services/translator/translator.service"; +import { MenuController } from "@ionic/angular"; import { AuthenticationService } from "src/app/hmg-common/services/authentication/authentication.service"; import { SMSCheckResponse } from "src/app/hmg-common/services/authentication/models/smscheck.response"; -import { AuthenticatedUser } from 'src/app/hmg-common/services/authentication/models/authenticated-user'; +import { AuthenticatedUser } from "src/app/hmg-common/services/authentication/models/authenticated-user"; +import { MenuService } from "src/app/hmg-common/services/menu/menuservice.service"; +import { MenuResponse } from "src/app/hmg-common/services/menu/models/menu-response"; +import { CommonService } from "src/app/hmg-common/services/common/common.service"; @Component({ - selector: 'app-home', - templateUrl: './home.page.html', - styleUrls: ['./home.page.scss'], + selector: "app-home", + templateUrl: "./home.page.html", + styleUrls: ["./home.page.scss"] }) export class HomePage implements OnInit { - userData: any ={}; - user_image : any = "../assets/imgs/profile.png"; - constructor(public ts: TranslatorService, public menu: MenuController, public authService: AuthenticationService ) { } + userData: any = {}; + user_image: any = "../assets/imgs/profile.png"; + menuList: any = []; + constructor( + public ts: TranslatorService, + public menu: MenuController, + public authService: AuthenticationService, + public menuService: MenuService, + public common: CommonService + ) {} ngOnInit() { this.getUserDetails(); + this.getMenu(); } - private openMenu(){ + + private openMenu() { this.menu.toggle(); } - private getUserDetails(){ - const user = this.authService.loadAuthenticatedUser().subscribe((user: AuthenticatedUser) => { + private getUserDetails() { + const user = this.authService + .loadAuthenticatedUser() + .subscribe((user: AuthenticatedUser) => { if (user) { - this.userData=user; + this.userData = user; console.log(user); - }else{ + } else { console.log(user); } - }) - + }); + } + private getMenu() { + this.menuService.getMenu().subscribe((result: MenuResponse) => { + this.handleMenuResult(result); + }); + } + private handleMenuResult(result) { + if (this.common.validResponse(result)) { + if (this.common.hasData(result.List_Menu)) { + this.menuList = result.List_Menu; + } + } } -// private getMenu(){ -// this.menuService.getMenu(). -// subscribe((result: MenuResponse) => { -// this.handleMenuResult(result); -// }); -// } -// private handleMenuResult(result){ -// if (this.common.validResponse(result)) { -// if (this.common.hasData(result.List_Menu)) { -// this.menuList = result.List_Menu; -// } -// } } diff --git a/Mohem/src/theme/styles.scss b/Mohem/src/theme/styles.scss index 307a507a..7b52e4e6 100644 --- a/Mohem/src/theme/styles.scss +++ b/Mohem/src/theme/styles.scss @@ -139,10 +139,10 @@ ion-header ion-icon.icon.icon-ios.ion-ios-add{ color: (--darkgray); } .toolbar-background { - background: (--primary); - background: -moz-linear-gradient(45deg, (--primary) 0%, (--secondary) 36%,(--secondary) 59%, (--customnavy) 100%); - background: -webkit-linear-gradient(45deg, (--primary) 0%, (--secondary) 36%,(--secondary) 59%, (--customnavy) 100%); - background: linear-gradient(45deg, (--primary) 0%, (--secondary) 36%,(--secondary) 59%, (--customnavy) 100%); + background: var(--primary); + background: -moz-linear-gradient(45deg, var(--primary) 0%, var(--secondary) 36%,var(--secondary) 59%, var(--customnavy) 100%); + background: -webkit-linear-gradient(45deg, var(--primary) 0%, var(--secondary) 36%,var(--secondary) 59%, var(--customnavy) 100%); + background: linear-gradient(45deg, var(--primary) 0%, var(--secondary) 36%,var(--secondary) 59%, var(--customnavy) 100%); filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='var(--primary)', endColorstr='--var(customnavy)',GradientType=1 ); } /***************button bckground***************/ From 947fbda4da8dbd7d99c5a72c0f58d526fde0e849 Mon Sep 17 00:00:00 2001 From: Sultan Khan Date: Wed, 26 Jun 2019 17:35:41 +0300 Subject: [PATCH 3/3] update home --- .../authentication/authentication.service.ts | 485 ++++++++---------- 1 file changed, 222 insertions(+), 263 deletions(-) diff --git a/Mohem/src/app/hmg-common/services/authentication/authentication.service.ts b/Mohem/src/app/hmg-common/services/authentication/authentication.service.ts index e55ba276..69c0d4b7 100644 --- a/Mohem/src/app/hmg-common/services/authentication/authentication.service.ts +++ b/Mohem/src/app/hmg-common/services/authentication/authentication.service.ts @@ -32,73 +32,72 @@ 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 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"; - - /* 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 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( - public con: ConnectorService, - public cs: CommonService, - public ts: TranslatorService, - 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; - request.TokenID = user.TokenID; - request.P_USER_NAME = user.EMPLOYEE_NUMBER; - request.UserName = user.EMPLOYEE_NUMBER; - if (AuthenticationService.requireRelogin) { - this.sessionTimeOutDialog(); - } - } else { - this.cs.userNeedToReLogin(); - } - /* + + + 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 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'; + + /* 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; + + /*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( + public con: ConnectorService, + public cs: CommonService, + public ts: TranslatorService, + 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) { + 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; + if (AuthenticationService.requireRelogin) { + this.sessionTimeOutDialog(); + } + } else { + this.cs.userNeedToReLogin(); + } + /* else { if (automaticLogin) { this.cs.openUserLogin(); @@ -118,7 +117,6 @@ export class AuthenticationService { //request.isDentalAllowedBackend = false; return request; } - public authenticateAndSetPersonalInformation( request: EmailRequest, examinationInfo?: any @@ -164,71 +162,67 @@ 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 { - request.PatientID = 0; - request.TokenID = ""; - request.isDentalAllowedBackend = false; - request.isRegister = false; - return this.con.post( - AuthenticationService.loginURL, - request, - onError, - errorLabel - ); - } - public isAuthenticated(): boolean { - return AuthenticationService.user != null; - } + public getPublicRequest(): Request { + const request = new Request(); + this.setPublicFields(request); + return request; + } - /** - * 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: CheckActivationCodeResponse - ): Observable { - 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 login(request: LoginRequest, onError: any, errorLabel: string): Observable { + 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 + * 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: CheckActivationCodeResponse + ): Observable { + 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; @@ -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 @@ -428,52 +420,41 @@ export class AuthenticationService { return AuthenticationService.user; } */ - return AuthenticationService.user; - } + return AuthenticationService.user; + } - public checkUserAuthentication( - request: CheckUserAuthenticationRequest, - onError: any, - errorLabel: string - ): Observable { - this.setPublicFields(request); - return this.con.post( - AuthenticationService.login, - request, - onError, - errorLabel - ); - } - public checkActivationCode( - request: CheckActivationCodeRequest, - onError: any, - errorLabel: string - ): Observable { - this.setPublicFields(request); - return this.con.post( - AuthenticationService.activationCodeURL, - request, - onError, - errorLabel - ); - } + public checkUserAuthentication(request: CheckUserAuthenticationRequest, onError: any, errorLabel: string) + : Observable { + this.setPublicFields(request); + return this.con.post(AuthenticationService.userChecking, request, onError, errorLabel); + } - public checkSMS( - request: SMSCheckRequest, - onError: any, - errorLabel: string - ): Observable { - //this.setPublicFields(request); - return this.con.post( - AuthenticationService.smsCheck, - request, - onError, - errorLabel - ); - } + public checkActivationCode(request: CheckActivationCodeRequest, onError: any, errorLabel: string) + : Observable { + this.setPublicFields(request); + return this.con.post(AuthenticationService.activationCodeURL, request, onError, errorLabel); + } - /* + public checkSMS(request: SMSCheckRequest, onError: any, errorLabel: string) + : Observable { + this.setPublicFields(request); + return this.con.post(AuthenticationService.smsCheck, request, onError, errorLabel); + } + + public checkForgetSMS(request: SMSCheckRequest, onError: any, errorLabel: string) + : Observable { + this.setPublicFields(request); + return this.con.post(AuthenticationService.smsCheckForget, request, onError, errorLabel); + } + + public sendPublicSMS(request: SMSCheckRequest, onError: any, errorLabel: string) + : Observable { + this.setPublicFields(request); + return this.con.post(AuthenticationService.smsSendCode, request, onError, errorLabel); + } + + /* client side: id no , mobile no , zip code */ @@ -482,112 +463,90 @@ export class AuthenticationService { client side: id no , mobile no , zip code */ - public sendSmsForPatientRegisteration( - request: CheckPatientRegisterationRequest, - onError: any, - errorLabel: string - ): Observable { - this.setPublicFields(request); - request.TokenID = ""; - request.isRegister = false; - return this.con.post( - AuthenticationService.sendSmsForRegisterURL, - request, - onError, - errorLabel - ); - } + public sendSmsForPatientRegisteration(request: CheckPatientRegisterationRequest, onError: any, errorLabel: string) + : Observable { + 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 { - this.setPublicFields(request); - return this.con.post( - AuthenticationService.activationCodeURL, - request, - onError, - errorLabel - ); - } + public checkRegisterationActivationCode(request: CheckRegisterationCodeRequest, onError: any, errorLabel: string) + : Observable { + this.setPublicFields(request); + return this.con.post(AuthenticationService.activationCodeURL, request, onError, errorLabel); + } - public sendSMSForForgotFileNumber( - request: CheckUserAuthenticationRequest, - onError: any, - errorLabel: string - ): Observable { - this.setPublicFields(request); - request.TokenID = ""; - // request.PatientIdentificationID = ''; - // request.PatientID = 0; - //request.SearchType = 2; - //request.isRegister = false; - return this.con.post( - AuthenticationService.sendSMSForgotFileNoURL, - request, - onError, - errorLabel - ); - } + public sendForgetPassword(request: ForgetPassword, onError: any, errorLabel: string) + : Observable { + this.setPublicFields(request); + return this.con.post(AuthenticationService.smsSendCode, request, onError, errorLabel); + } - public forgotFileIdActivation( - request: CheckActivationCodeRequest, - onError: any, - errorLabel: string - ): Observable { - this.setPublicFields(request); - request.TokenID = ""; - request.PatientIdentificationID = ""; - // request.PatientID = 0; - request.SearchType = 2; - request.isRegister = false; - return this.con.post( - AuthenticationService.forgotFileIDURL, - request, - onError, - errorLabel - ); - } + public submitForgetPassword(request: ForgetPassword, onError: any, errorLabel: string) + : Observable { + this.setPublicFields(request); + return this.con.post(AuthenticationService.changePasswordForget, request, onError, errorLabel); + } - public isSAUDIIDValid(id: string): boolean { - if (!id) { - return false; + + public sendSMSForForgotFileNumber(request: CheckUserAuthenticationRequest, onError: any, errorLabel: string) + : Observable { + this.setPublicFields(request); + request.TokenID = ''; + //request.SearchType = 2; + //request.isRegister = false; + return this.con.post(AuthenticationService.sendSMSForgotFileNoURL, request, onError, errorLabel); } - 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) { + + public forgotFileIdActivation(request: CheckActivationCodeRequest, onError: any, errorLabel: string) + : Observable { + this.setPublicFields(request); + request.TokenID = ''; + request.SearchType = 2; + request.isRegister = false; + return this.con.post(AuthenticationService.forgotFileIDURL, request, onError, errorLabel); + } + + + public isSAUDIIDValid(id: string): boolean { + if (!id) { 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; + 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; } - sum += Number(b.charAt(0)) + Number(b.charAt(1)); - } else { - sum += Number(id.charAt(i)); + + 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)); + } + } + return sum % 10 === 0; } - } - return sum % 10 === 0; + } catch (err) {} + return false; } - } catch (err) {} - return false; - } - + public checkUserHasEmailDialog(): Observable { return Observable.create(observer => { if (this.isAuthenticatedUserHasRealEmail()) {