From a787f6797db9637fba7b9855eb94d5ae7d9feb5c Mon Sep 17 00:00:00 2001 From: ansariakhtar Date: Tue, 25 Jun 2019 09:43:58 +0300 Subject: [PATCH] Login API --- Mohem/src/app/app-routing.module.ts | 35 +++--- Mohem/src/app/app.component.scss | 112 ++++++++++++++++++ .../authentication/authentication.module.ts | 6 + .../forgot/forgot.component.html | 6 +- .../authentication/forgot/forgot.component.ts | 4 +- .../authentication/login/login.component.html | 8 +- .../authentication/login/login.component.ts | 49 ++++---- .../sms-page/sms-page.module.ts | 26 ++++ .../sms-page/sms-page.page.html | 36 ++++++ .../sms-page/sms-page.page.scss | 0 .../sms-page/sms-page.page.spec.ts | 27 +++++ .../authentication/sms-page/sms-page.page.ts | 38 ++++++ .../authentication/authentication.service.ts | 22 ++-- .../models/check-user-auth.request.ts | 16 ++- .../services/common/common.service.ts | 3 + .../app/hmg-common/services/models/request.ts | 1 + Mohem/src/app/hmg-common/ui/sms/sms.page.html | 77 +++++------- 17 files changed, 358 insertions(+), 108 deletions(-) create mode 100644 Mohem/src/app/authentication/sms-page/sms-page.module.ts create mode 100644 Mohem/src/app/authentication/sms-page/sms-page.page.html create mode 100644 Mohem/src/app/authentication/sms-page/sms-page.page.scss create mode 100644 Mohem/src/app/authentication/sms-page/sms-page.page.spec.ts create mode 100644 Mohem/src/app/authentication/sms-page/sms-page.page.ts diff --git a/Mohem/src/app/app-routing.module.ts b/Mohem/src/app/app-routing.module.ts index 42c149de..613e47bc 100644 --- a/Mohem/src/app/app-routing.module.ts +++ b/Mohem/src/app/app-routing.module.ts @@ -1,18 +1,19 @@ -import { NgModule } from '@angular/core'; -import { PreloadAllModules, RouterModule, Routes } from '@angular/router'; +import { NgModule } from '@angular/core'; +import { PreloadAllModules, RouterModule, Routes } from '@angular/router'; + +const routes: Routes = [ + { path: '', redirectTo: 'authentication/login', pathMatch: 'full' }, + { + path: 'authentication', loadChildren: './authentication/authentication.module#AuthenticationPageModule', + data: { preload: true, delay: 1000 } + }, { path: 'sms-page', loadChildren: './authentication/sms-page/sms-page.module#SmsPagePageModule' } -const routes: Routes = [ - { path: '', redirectTo: 'authentication/login', pathMatch: 'full' }, - { - path: 'authentication', loadChildren: './authentication/authentication.module#AuthenticationPageModule', - data: { preload: true, delay: 1000 } - } -]; - -@NgModule({ - imports: [ - RouterModule.forRoot(routes, { preloadingStrategy: PreloadAllModules }) - ], - exports: [RouterModule] -}) -export class AppRoutingModule { } +]; + +@NgModule({ + imports: [ + RouterModule.forRoot(routes, { preloadingStrategy: PreloadAllModules }) + ], + exports: [RouterModule] +}) +export class AppRoutingModule { } diff --git a/Mohem/src/app/app.component.scss b/Mohem/src/app/app.component.scss index e69de29b..88fe6829 100644 --- a/Mohem/src/app/app.component.scss +++ b/Mohem/src/app/app.component.scss @@ -0,0 +1,112 @@ +/* +header +*/ +.menu-header { + height: 2.5cm; + } + + .content-ios:not([no-bounce]) > .scroll-content::before { + bottom: 0; + } + + .menu-header .logo { + position: absolute; + left: 0.6cm; + top: 0.9cm; + width: 1.6cm; + } + + .menu-header .background { + height: 1.5cm; + width: 100%; + } + + /* title */ + .title-v-spacer { + height: 0.7cm; + } + + .suliman-title { + margin-left: 0.3cm; + margin-right: 0.3cm; + font-weight: bold; + font-size: 0.5cm; + } + + .group-title { + margin-left: 0.4cm; + margin-right: 0.4cm; + font-size: 0.4cm; + } + + /* + items + */ + .items-buttons-spacer { + height: 10%; + } + /* + user information + */ + .user-v-spacer { + height: 0.5cm; + } + + .user-name-title { + margin-left: 0.3cm; + margin-right: 0.3cm; + font-weight: bold; + } + + .file-id-title { + margin-left: 0.4cm; + margin-right: 0.4cm; + } + + .social-media-container { + position: absolute !important; + width: 100%; + bottom: 0.2cm; + background-color: white; + } + + .icon-spacer { + margin-right: 0.3cm; + margin-left: 0.3cm; + } + + /*mobile Landscape */ + @media only screen and (min-device-height: 0px) and (max-device-height: 515px) and (orientation: landscape) { + .social-media-container { + display: none; + } + } + .info-container { + overflow-y: scroll; + width: 100%; + position: absolute; + top: 2.6cm; + bottom: 0.2cm; + padding-bottom: 4.5cm; + } + + @media only screen and (orientation: landscape) { + .info-container { + padding-bottom: 0.2cm; + } + } + + .member { + border-bottom-color: var(--ion-color-medium) !important; + border-bottom-width: 0.02cm; + border-bottom-style: solid; + /* margin-left: 0.4cm; */ + } + + .selected-member { + border-bottom-color: var(--ion-color-secondary) !important; + border-bottom-width: 0.02cm; + border-bottom-style: solid; + margin-left: 0.2cm; + } + \ No newline at end of file diff --git a/Mohem/src/app/authentication/authentication.module.ts b/Mohem/src/app/authentication/authentication.module.ts index 9b270564..c1551cb3 100644 --- a/Mohem/src/app/authentication/authentication.module.ts +++ b/Mohem/src/app/authentication/authentication.module.ts @@ -17,6 +17,7 @@ import { SearchableOptionsModule } from '../hmg-common/ui/searchable-select/sear import { MobileNumberModule } from 'src/app/hmg-common/ui/mobile-number/mobile-number.module'; 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'; @@ -36,6 +37,10 @@ const routes: Routes = [ { path: 'agreement', component: AgreementComponent + }, + { + path: 'smspage', + component: SmsPagePage } ] } @@ -60,6 +65,7 @@ const routes: Routes = [ LoginComponent, ForgotComponent, AgreementComponent, + SmsPagePage ], providers:[ FingerprintAIO, diff --git a/Mohem/src/app/authentication/forgot/forgot.component.html b/Mohem/src/app/authentication/forgot/forgot.component.html index 8c8d2004..caaaa9df 100644 --- a/Mohem/src/app/authentication/forgot/forgot.component.html +++ b/Mohem/src/app/authentication/forgot/forgot.component.html @@ -1,9 +1,11 @@ - - + + {{'login,forgot-password' | translate}} + + diff --git a/Mohem/src/app/authentication/forgot/forgot.component.ts b/Mohem/src/app/authentication/forgot/forgot.component.ts index 8b7f7e30..949f40a2 100644 --- a/Mohem/src/app/authentication/forgot/forgot.component.ts +++ b/Mohem/src/app/authentication/forgot/forgot.component.ts @@ -58,8 +58,8 @@ export class ForgotComponent implements OnInit,OnDestroy { private sendSMSForForgotPassword() { const request = new CheckUserAuthenticationRequest(); - request.PatientMobileNumber = this.countryCode.number; - request.ZipCode = CountryCode.localCode(this.countryCode.code); + //request.PatientMobileNumber = this.countryCode.number; + //request.ZipCode = CountryCode.localCode(this.countryCode.code); this.authService.sendSMSForForgotFileNumber( request, diff --git a/Mohem/src/app/authentication/login/login.component.html b/Mohem/src/app/authentication/login/login.component.html index 043e923d..9de58fab 100644 --- a/Mohem/src/app/authentication/login/login.component.html +++ b/Mohem/src/app/authentication/login/login.component.html @@ -16,18 +16,18 @@ {{ts.trPK('login','username')}} - + {{ts.trPK('login','password')}} - + -
+
@@ -38,7 +38,7 @@
- {{ts.trPK('login','login')}} + {{ts.trPK('login','login')}}

diff --git a/Mohem/src/app/authentication/login/login.component.ts b/Mohem/src/app/authentication/login/login.component.ts index e547c75a..fcb916f8 100644 --- a/Mohem/src/app/authentication/login/login.component.ts +++ b/Mohem/src/app/authentication/login/login.component.ts @@ -31,6 +31,11 @@ export class LoginComponent implements OnInit, OnDestroy { isSupportAr:boolean=false; isAppleStore:boolean=false; memberLogin: any = {}; + + private password: string; + private language: string; + private username : string; + constructor( public cs: CommonService, public authService: AuthenticationService, @@ -58,6 +63,14 @@ export class LoginComponent implements OnInit, OnDestroy { } public changeLanguage(){ this.ts.switchLanguage(); + console.log(this.ts.getCurrentSystemLanguageName()); + if(TranslatorService.CURRENT_LANGUAGE == TranslatorService.EN) + { + this.language = "US"; + } + else{ + this.language = "AR"; + } } private checkIfLoggedInBefore() { this.cs.startLoading(); @@ -135,10 +148,10 @@ export class LoginComponent implements OnInit, OnDestroy { private initializeForAuthentictedUser(user: AuthenticatedUser) { this.ngZone.run(() => { - this.isMobileFingerPrint = true; - this.FingerPrintPatientIdentificationID = user.IdentificationNo; - this.mobileNumber = user.MobileNumber; - this.zipCode = CountryCode.localCode(user.ZipCode); + //this.isMobileFingerPrint = true; + //this.FingerPrintPatientIdentificationID = user.IdentificationNo; + //this.mobileNumber = user.MobileNumber; + //this.zipCode = CountryCode.localCode(user.ZipCode); }); } @@ -157,16 +170,7 @@ export class LoginComponent implements OnInit, OnDestroy { }).catch((error: any) => console.log(error)); } - - /** - we need holders here since the country code maybe is not loaded yet for automatic login - */ - private mobileNumber: string; - private zipCode: string; - public onLogin() { - - this.checkUserAuthentication(); } @@ -344,17 +348,17 @@ export class LoginComponent implements OnInit, OnDestroy { private checkUserAuthentication() { const request = new CheckUserAuthenticationRequest(); - request.PatientMobileNumber = this.mobileNumber; - request.ZipCode = this.zipCode; - request.isRegister = false; - request.TokenID = ''; - + request.P_USER_NAME = this.username; + request.P_LANGUAGE = this.language; + request.P_PASSWORD = this.password; + console.log(request); this.authService.checkUserAuthentication( request, () => { - }, this.ts.trPK('general', 'ok')).subscribe((result: CheckUserAuthenticationResponse) => { if (this.cs.validResponse(result)) { + console.log(result); + this.cs.openSMSPage(); this.loginTokenID = result.LogInTokenID; this.patientOutSA = result.PatientOutSA; this.isMobileFingerPrint = false; @@ -399,7 +403,7 @@ export class LoginComponent implements OnInit, OnDestroy { private FingerPrintPatientIdentificationID: string; private checkActivationCode(readedCode?) { - const request = new CheckActivationCodeRequest(); + /*const request = new CheckActivationCodeRequest(); request.IsMobileFingerPrint = this.isMobileFingerPrint; request.FingerPrintPatientIdentificationID = this.FingerPrintPatientIdentificationID; request.LogInTokenID = this.loginTokenID; @@ -408,6 +412,8 @@ export class LoginComponent implements OnInit, OnDestroy { request.IsSilentLogin = !readedCode; request.PatientMobileNumber = this.mobileNumber; request.ZipCode = this.zipCode; + request.isRegister = false;*/ + // request.SearchType = this.loginType; // if (this.loginType === LoginComponent.IDENTIFCIATION_LOGIN_TYPE) { // request.PatientIdentificationID = this.id; @@ -416,7 +422,6 @@ export class LoginComponent implements OnInit, OnDestroy { // request.PatientID = Number(this.id); // request.PatientIdentificationID = ''; // } - request.isRegister = false; // this.authService.checkActivationCode( // request, // () => { @@ -440,7 +445,7 @@ export class LoginComponent implements OnInit, OnDestroy { if (this.authService.isAgreedBefore()) { this.cs.openHome(); } else { - this.cs.openAgreement(); + //this.cs.openAgreement(); } }); } diff --git a/Mohem/src/app/authentication/sms-page/sms-page.module.ts b/Mohem/src/app/authentication/sms-page/sms-page.module.ts new file mode 100644 index 00000000..049e14a0 --- /dev/null +++ b/Mohem/src/app/authentication/sms-page/sms-page.module.ts @@ -0,0 +1,26 @@ +import { NgModule } from '@angular/core'; +import { CommonModule } from '@angular/common'; +import { FormsModule } from '@angular/forms'; +import { Routes, RouterModule } from '@angular/router'; + +import { IonicModule } from '@ionic/angular'; + +import { SmsPagePage } from './sms-page.page'; + +const routes: Routes = [ + { + path: 'smspage', + component: SmsPagePage + } +]; + +@NgModule({ + imports: [ + CommonModule, + FormsModule, + IonicModule, + RouterModule.forChild(routes) + ], + declarations: [SmsPagePage] +}) +export class SmsPagePageModule {} diff --git a/Mohem/src/app/authentication/sms-page/sms-page.page.html b/Mohem/src/app/authentication/sms-page/sms-page.page.html new file mode 100644 index 00000000..c49cc795 --- /dev/null +++ b/Mohem/src/app/authentication/sms-page/sms-page.page.html @@ -0,0 +1,36 @@ + + + {{'verificationcode.verificationcode' | translate}} + + + + + + + + + + + + +

{{'verificationcode.title' | translate}}{{'verificationcode.verificationcode' | translate}} {{'verificationcode.by' | translate}}{{'verificationcode.sms' | translate}}{{'verificationcode.instruct' | translate}}{{'general.submit' | translate}}

+
+
+
+

+ +
+

{{displayTime}}

+

+ + {{'verificationcode.verificationcode' | translate}} + + + +
+
+ +
+ +
+
\ No newline at end of file diff --git a/Mohem/src/app/authentication/sms-page/sms-page.page.scss b/Mohem/src/app/authentication/sms-page/sms-page.page.scss new file mode 100644 index 00000000..e69de29b diff --git a/Mohem/src/app/authentication/sms-page/sms-page.page.spec.ts b/Mohem/src/app/authentication/sms-page/sms-page.page.spec.ts new file mode 100644 index 00000000..48e022a2 --- /dev/null +++ b/Mohem/src/app/authentication/sms-page/sms-page.page.spec.ts @@ -0,0 +1,27 @@ +import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core'; +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; + +import { SmsPagePage } from './sms-page.page'; + +describe('SmsPagePage', () => { + let component: SmsPagePage; + let fixture: ComponentFixture; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [ SmsPagePage ], + schemas: [CUSTOM_ELEMENTS_SCHEMA], + }) + .compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(SmsPagePage); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/Mohem/src/app/authentication/sms-page/sms-page.page.ts b/Mohem/src/app/authentication/sms-page/sms-page.page.ts new file mode 100644 index 00000000..9d67eec3 --- /dev/null +++ b/Mohem/src/app/authentication/sms-page/sms-page.page.ts @@ -0,0 +1,38 @@ +import { Component, OnInit } from '@angular/core'; +import { ElementRef} from '@angular/core'; +import { NavController } from '@ionic/angular'; +import { TranslatorService } from 'src/app/hmg-common/services/translator/translator.service'; +import { CommonService } from 'src/app/hmg-common/services/common/common.service'; +import { SharedDataService } from 'src/app/hmg-common/services/shared-data-service/shared-data.service'; +@Component({ + selector: 'app-sms-page', + templateUrl: './sms-page.page.html', + styleUrls: ['./sms-page.page.scss'], +}) +export class SmsPagePage implements OnInit { + + Channel: number=0; + activationCode: string; + P_SESSION_ID: number; + timeInSeconds: any; + time:any; + runTimer:any; + hasStarted: any; + hasFinished: any; + remainingTime:any; + displayTime:any; + loginTokenID:string; +public isForgetPwd:boolean=false; +public isExpiredPwd:boolean=false; +public count:number=0; + + constructor(public navCtrl: NavController, + public translate: TranslatorService, + public common:CommonService, + private elementRef:ElementRef, + public sharedData:SharedDataService) { } + + ngOnInit() { + } + +} 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 0a70b492..b5afd01e 100644 --- a/Mohem/src/app/hmg-common/services/authentication/authentication.service.ts +++ b/Mohem/src/app/hmg-common/services/authentication/authentication.service.ts @@ -36,6 +36,9 @@ 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'; @@ -90,12 +93,13 @@ export class AuthenticationService { } public setPublicFields(request: Request): Request { - request.VersionID = 3.6; - request.Channel = 3; + request.VersionID = 1; + request.Channel = 31; request.LanguageID = TranslatorService.getCurrentLanguageCode(); - request.IPAdress = '10.10.10.10'; + //request.IPAdress = '10.10.10.10'; request.SessionID = 'any thing'; // ??? required for not authorized login funny - request.isDentalAllowedBackend = false; + request.MobileType = "android"; + //request.isDentalAllowedBackend = false; return request; } @@ -420,7 +424,7 @@ export class AuthenticationService { public checkUserAuthentication(request: CheckUserAuthenticationRequest, onError: any, errorLabel: string) : Observable { this.setPublicFields(request); - return this.con.post(AuthenticationService.checkUserAuthURL, request, onError, errorLabel); + return this.con.post(AuthenticationService.login, request, onError, errorLabel); } public checkActivationCode(request: CheckActivationCodeRequest, onError: any, errorLabel: string) @@ -466,8 +470,8 @@ export class AuthenticationService { request.TokenID = ''; request.PatientIdentificationID = ''; request.PatientID = 0; - request.SearchType = 2; - request.isRegister = false; + //request.SearchType = 2; + //request.isRegister = false; return this.con.post(AuthenticationService.sendSMSForgotFileNoURL, request, onError, errorLabel); } @@ -540,7 +544,7 @@ export class AuthenticationService { } else { this.cs.presentConfirmDialog(this.ts.trPK('login', 'enter-email'), () => { - this.cs.openPatientProfile(); + //this.cs.openPatientProfile(); observer.complete(); }); } @@ -564,7 +568,7 @@ export class AuthenticationService { private sessionTimeOutDialog() { this.cs.presentConfirmDialog(this.ts.trPK('general', 'idle-relogin'), () => { - this.cs.openUserLogin(); + //this.cs.openUserLogin(); }); } diff --git a/Mohem/src/app/hmg-common/services/authentication/models/check-user-auth.request.ts b/Mohem/src/app/hmg-common/services/authentication/models/check-user-auth.request.ts index 5121f239..45314c6f 100644 --- a/Mohem/src/app/hmg-common/services/authentication/models/check-user-auth.request.ts +++ b/Mohem/src/app/hmg-common/services/authentication/models/check-user-auth.request.ts @@ -1,10 +1,14 @@ import { Request } from '../../models/request'; export class CheckUserAuthenticationRequest extends Request { - PatientIdentificationID: string; // id - PatientMobileNumber: string; // phone number - ZipCode: string; - SearchType: number; // 1 for id , 2 for file no - isRegister: boolean; // false - LogInTokenID?: string; + // PatientIdentificationID: string; // id + // PatientMobileNumber: string; // phone number + // ZipCode: string; + // SearchType: number; // 1 for id , 2 for file no + // isRegister: boolean; // false + // LogInTokenID?: string; + + P_USER_NAME:string; + P_LANGUAGE: string; + P_PASSWORD: string; } 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 2a54f10e..7cdaa3ab 100644 --- a/Mohem/src/app/hmg-common/services/common/common.service.ts +++ b/Mohem/src/app/hmg-common/services/common/common.service.ts @@ -899,6 +899,9 @@ export class CommonService { public openUserForgot() { this.nav.navigateForward(["/authentication/forgot"]); } + public openSMSPage() { + this.nav.navigateForward(["/authentication/smspage"]); + } public navigateTo(url: string) { diff --git a/Mohem/src/app/hmg-common/services/models/request.ts b/Mohem/src/app/hmg-common/services/models/request.ts index d88b96f0..77dee9a3 100644 --- a/Mohem/src/app/hmg-common/services/models/request.ts +++ b/Mohem/src/app/hmg-common/services/models/request.ts @@ -12,6 +12,7 @@ export class Request { public IsIrisPrescription: boolean; public TokenID: string; public SessionID: string; + public MobileType: string; public PatientIdentificationID: string; public PatientMobileNumber: string; public BookedBy?: number; diff --git a/Mohem/src/app/hmg-common/ui/sms/sms.page.html b/Mohem/src/app/hmg-common/ui/sms/sms.page.html index ac32038f..c49cc795 100644 --- a/Mohem/src/app/hmg-common/ui/sms/sms.page.html +++ b/Mohem/src/app/hmg-common/ui/sms/sms.page.html @@ -1,51 +1,36 @@ - - {{'sms,title' | translate}} - + + {{'verificationcode.verificationcode' | translate}} + - - - - - - - - - -
{{ 'home,verification-code-text'| translate}}
-
- -
{{mobile}}
-
-
- - - {{ 'h2o,verification_message' | translate}} - - - - - - - {{ 'h2o,validation_message' | translate}} - - - {{displayTime}} - + + + + + + - - -

{{'h2o,code_failure' | translate}}

-
- - {{'h2o,resend' | translate}} - -
- - - {{'general,submit' | translate}} - + + +

{{'verificationcode.title' | translate}}{{'verificationcode.verificationcode' | translate}} {{'verificationcode.by' | translate}}{{'verificationcode.sms' | translate}}{{'verificationcode.instruct' | translate}}{{'general.submit' | translate}}

+
-
-
\ No newline at end of file +
+

+ +
+

{{displayTime}}

+

+ + {{'verificationcode.verificationcode' | translate}} + + + +
+
+ +
+ +
+
\ No newline at end of file