push Enad code workList page
commit
0d05073e71
@ -0,0 +1,50 @@
|
||||
<ion-header>
|
||||
<ion-toolbar class="header-toolbar">
|
||||
<ion-buttons slot="start">
|
||||
<ion-back-button color="light" class="btnBack" ></ion-back-button>
|
||||
</ion-buttons>
|
||||
<ion-title color="light" > {{'login,verify-login' | translate}}</ion-title>
|
||||
</ion-toolbar>
|
||||
</ion-header>
|
||||
|
||||
|
||||
|
||||
<ion-content padding>
|
||||
<ion-grid>
|
||||
|
||||
<ion-row class="ion-justify-content-center">
|
||||
<ion-col [size]="4">
|
||||
<img [src]="logo" class="logo" />
|
||||
</ion-col>
|
||||
</ion-row>
|
||||
<ion-row class="description">
|
||||
<ion-col size="12">
|
||||
<!-- <type-writer *ngIf="onlySMSBox" [text]="'login,verify-login-with' | translate" class="description"
|
||||
color="primary" fontSize="0.55cm" lineHeight="1cm" fontSize="0.55cm"></type-writer>
|
||||
-->
|
||||
<div *ngIf="onlySMSBox"><p>{{ts.trPK('login','verify-login-with')}}</p></div>
|
||||
<!-- <type-writer *ngIf="!onlySMSBox" [text]="'login, verify-fingerprint' | translate" class="description"
|
||||
color="primary" fontSize="0.55cm" lineHeight="1cm" fontSize="0.55cm"></type-writer>
|
||||
-->
|
||||
<div *ngIf="!onlySMSBox"><p>{{ts.trPK('login','verify-fingerprint')}}</p></div>
|
||||
|
||||
|
||||
</ion-col>
|
||||
</ion-row>
|
||||
|
||||
<page-trailer [small]="true"></page-trailer>
|
||||
|
||||
<ion-row [dir]="direction" class="zoomIn">
|
||||
<ng-container *ngFor="let buttonsGroup of buttons">
|
||||
<ion-col *ngFor="let button of buttonsGroup" [size]="6">
|
||||
<app-button (click)="confirm(button)" [title]="button.title | translate " [icon]="button.icon"
|
||||
[settings]="button.settings" [strong]="button.txt" [class]="button.class" [disabled]="button.disabled"
|
||||
*ngIf="button.visible">
|
||||
</app-button>
|
||||
|
||||
</ion-col>
|
||||
</ng-container>
|
||||
</ion-row>
|
||||
</ion-grid>
|
||||
|
||||
</ion-content>
|
||||
@ -0,0 +1,27 @@
|
||||
import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
|
||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { ConfirmLoginComponent } from './confirm-login.component';
|
||||
|
||||
describe('ConfirmLoginComponent', () => {
|
||||
let component: ConfirmLoginComponent;
|
||||
let fixture: ComponentFixture<ConfirmLoginComponent>;
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [ ConfirmLoginComponent ],
|
||||
schemas: [CUSTOM_ELEMENTS_SCHEMA],
|
||||
})
|
||||
.compileComponents();
|
||||
}));
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(ConfirmLoginComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
||||
@ -0,0 +1,379 @@
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import {ButtonSettings} from "src/app/hmg-common/ui/button/models/button-settingsl";
|
||||
import {TranslatorService} from "src/app/hmg-common/services/translator/translator.service";
|
||||
import { CommonService } from 'src/app/hmg-common/services/common/common.service';
|
||||
import { LoginRequest } from 'src/app/hmg-common/services/authentication/models/login.request';
|
||||
import { AuthenticationService } from 'src/app/hmg-common/services/authentication/authentication.service';
|
||||
import { SharedDataService } from 'src/app/hmg-common/services/shared-data-service/shared-data.service';
|
||||
import { SendActivationByType } from '../models/sendActivationByType';
|
||||
import { FingerprintAIO } from '@ionic-native/fingerprint-aio/ngx';
|
||||
import { GetLoginInfoRequest } from "../../hmg-common/services/authentication/models/get-login-info.request";
|
||||
import { GetLoginInfoResponse } from "../../hmg-common/services/authentication/models/get-login-info.response";
|
||||
import { SMSCheckRequest } from "src/app/hmg-common/services/authentication/models/smscheck.request";
|
||||
import { SMSCheckResponse } from "src/app/hmg-common/services/authentication/models/smscheck.response";
|
||||
import { PushService } from 'src/app/hmg-common/services/push/push.service';
|
||||
|
||||
|
||||
@Component({
|
||||
selector: 'app-confirm-login',
|
||||
templateUrl: './confirm-login.component.html',
|
||||
styleUrls: ['./confirm-login.component.scss'],
|
||||
})
|
||||
export class ConfirmLoginComponent implements OnInit {
|
||||
public logo = "assets/imgs/CS.png";
|
||||
public buttons:any=[];
|
||||
isFaceorFinger: any;
|
||||
onlySMSBox: any = true;
|
||||
loginData:any;
|
||||
selectedOption: any;
|
||||
lastLogin: any;
|
||||
loginTokenID:any
|
||||
deviceToken:any;
|
||||
|
||||
constructor(
|
||||
public ts: TranslatorService,
|
||||
public cs: CommonService,
|
||||
public authService: AuthenticationService,
|
||||
public sharedData: SharedDataService,
|
||||
private faio: FingerprintAIO,
|
||||
public pushService: PushService,
|
||||
|
||||
|
||||
) {
|
||||
this.loginData= this.sharedData.getSharedData(AuthenticationService.LOGIN_DATA, false);
|
||||
console.log(this.loginData);
|
||||
this.deviceToken= this.cs.sharedService.getSharedData(AuthenticationService.DEVICE_TOKEN, false);
|
||||
console.log("deviceToken :"+this.deviceToken);
|
||||
//if device token undefind
|
||||
if(this.deviceToken == undefined){
|
||||
this.deviceToken = localStorage.getItem("deviceToken");
|
||||
|
||||
}
|
||||
this.lastLogin = this.cs.sharedService.getSharedData(AuthenticationService.LAST_LOGIN, false);
|
||||
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
//**checkIfAvailable FAIO **//
|
||||
this.checkIfAvailable();
|
||||
//**getSharedData of IMEI_USER_DATA and REGISTER_DATA_FOR_LOGIIN to set defult value **//
|
||||
|
||||
// this.setDefault();
|
||||
|
||||
|
||||
this.button();
|
||||
}
|
||||
|
||||
checkIfAvailable() {
|
||||
this.faio.isAvailable().then(
|
||||
options => {
|
||||
this.isFaceorFinger = options;
|
||||
if (this.isFaceorFinger === 'finger' && this.lastLogin === 1) {
|
||||
this.selectedOption = 2;
|
||||
this.cs.presentConfirmDialog(
|
||||
this.ts.trPK("login", "biometric-support"),
|
||||
() => {
|
||||
this.presentBiometricDialog();
|
||||
this.cs.sharedService.setSharedData(
|
||||
this.selectedOption,
|
||||
AuthenticationService.LAST_LOGIN
|
||||
);
|
||||
},
|
||||
() => { }
|
||||
);
|
||||
}
|
||||
this.button();
|
||||
},
|
||||
() => {
|
||||
this.isFaceorFinger = null;
|
||||
this.button();
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
button() {
|
||||
console.log("button");
|
||||
|
||||
this.buttons = [
|
||||
[{
|
||||
title: "login,verify-with-fingerprint",
|
||||
url: null,
|
||||
icon: "assets/icon/login/102.png",
|
||||
settings: new ButtonSettings(true, true, true, true),
|
||||
value: 2,
|
||||
disabled: this.isFaceorFinger === "finger" ? false : true,
|
||||
visible: this.onlySMSBox
|
||||
},
|
||||
{
|
||||
title: "login,verify-with-faceid",
|
||||
url: null,
|
||||
icon: "assets/icon/login/101.png",
|
||||
settings: new ButtonSettings(true, true, true, true),
|
||||
value: 3,
|
||||
disabled: this.isFaceorFinger === "face" ? false : true,
|
||||
visible: this.onlySMSBox
|
||||
},
|
||||
{
|
||||
title: "login,verify-with-whatsapp",
|
||||
url: null,
|
||||
icon: "assets/icon/login/104.png",
|
||||
settings: new ButtonSettings(true, true, true, true),
|
||||
value: 4,
|
||||
visible: true
|
||||
},
|
||||
{
|
||||
title: "login,verify-with-sms",
|
||||
url: null,
|
||||
icon: "assets/icon/login/103.png",
|
||||
settings: new ButtonSettings(true, true, true, true),
|
||||
value: 1,
|
||||
visible: true
|
||||
}
|
||||
]
|
||||
];
|
||||
}
|
||||
|
||||
confirm(el: any) {
|
||||
console.log("confirm:"+ el );
|
||||
this.selectedOption = this.selectedOption && !this.onlySMSBox ? this.selectedOption : el.value;
|
||||
switch (el.value) {
|
||||
case 1:
|
||||
console.log(el.value);
|
||||
this.loginWithSMS(el);
|
||||
break;
|
||||
case 2:
|
||||
console.log(el.value);
|
||||
|
||||
this.loginWithFingurePrint(el);
|
||||
break;
|
||||
case 3:
|
||||
console.log(el.value);
|
||||
|
||||
this.faceReconization(el);
|
||||
break;
|
||||
case 4:
|
||||
console.log(el.value);
|
||||
|
||||
this.loginWithWhatsapp(el);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
this.cs.sharedService.setSharedData(
|
||||
this.selectedOption,
|
||||
AuthenticationService.LAST_LOGIN
|
||||
);
|
||||
}
|
||||
|
||||
loginWithSMS(el) {
|
||||
console.log("loginWithSMS: "+ el);
|
||||
|
||||
if (!el.disabled) {
|
||||
|
||||
// if (this.user && !this.registerd_data) {
|
||||
//calling because i dont have token id which required to the send activation code
|
||||
/// this.checkUserAuthentication(1);
|
||||
// this.checkUserAuthentication(); ***
|
||||
|
||||
// } else {
|
||||
if (this.loginData.LogInTokenID) {
|
||||
this.sendActivationCode(1);
|
||||
} else {
|
||||
// this.checkUserAuthentication(1);
|
||||
// this.checkUserAuthentication();**
|
||||
|
||||
}
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
loginWithWhatsapp(el) {
|
||||
if (!el.disabled) {
|
||||
// if (this.user && !this.registerd_data) {
|
||||
//calling because i dont have token id which required to the send activation code
|
||||
// this.checkUserAuthentication(2);
|
||||
// } else {
|
||||
if (this.loginData.LogInTokenID) {
|
||||
this.sendActivationCode(2);
|
||||
} else {
|
||||
// this.checkUserAuthentication(2);
|
||||
}
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
public sendActivationCode(type: number) {
|
||||
let request = new SendActivationByType();
|
||||
this.authService.setPublicFields(request);
|
||||
request.OTP_SendType = type;
|
||||
request.MobileNumber = this.loginData.MobileNumber;
|
||||
request.IsMobileFingerPrint =0;
|
||||
request.P_USER_NAME=this.loginData.P_USER_NAME;
|
||||
request.LogInTokenID =this.loginData.LogInTokenID;
|
||||
request.P_LEGISLATION_CODE ="SA";
|
||||
// request.VersionID ="2.0";
|
||||
|
||||
|
||||
|
||||
// request.LanguageID = imeiData && imeiData.PreferredLanguage || request.LanguageID;
|
||||
this.authService
|
||||
.sendActivationCodeByType(
|
||||
request,
|
||||
() => { },
|
||||
this.ts.trPK("general", "ok")
|
||||
)
|
||||
.subscribe((result: any) => {
|
||||
if (result.isSMSSent) {
|
||||
this.cs.sharedService.setSharedData({
|
||||
MobileNumber: this.loginData.mobileNumber,
|
||||
loginType: this.selectedOption
|
||||
},
|
||||
SMSCheckRequest.SHARED_DATA
|
||||
);
|
||||
|
||||
this.cs.openSMSPage();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
loginWithFingurePrint(el: any) {
|
||||
if (!el.disabled) {
|
||||
this.startBiometricLoginIfAvailable();
|
||||
}
|
||||
}
|
||||
faceReconization(el: any) {
|
||||
if (!el.disabled) {
|
||||
this.startBiometricLoginIfAvailable();
|
||||
}
|
||||
}
|
||||
|
||||
private startBiometricLoginIfAvailable() {
|
||||
// this.setting.isBiometricsEnabled().then(result => {
|
||||
// console.log(result);
|
||||
this.faio.isAvailable().then(
|
||||
options => {
|
||||
// if biometric supported
|
||||
//if (result) {
|
||||
// ask if login with face or finger
|
||||
this.presentBiometricDialog();
|
||||
// } else {
|
||||
// //ask to enable biometric
|
||||
// this.getPermissionToActivateBiometric();
|
||||
// }
|
||||
},
|
||||
() => {
|
||||
alert("not avaliable ")
|
||||
// if biometric not supported do nothing unless
|
||||
// user session time out from last login
|
||||
// if (AuthenticationService.isRequireRelogin()) {
|
||||
// this.initializeInputsFromSessionTimeOut(user);
|
||||
// }
|
||||
// this.hideSplashScreen(true);
|
||||
}
|
||||
);
|
||||
//});
|
||||
}
|
||||
|
||||
private presentBiometricDialog() {
|
||||
this.faio
|
||||
.show({
|
||||
clientId: "Fingerprint Authetnciation",
|
||||
clientSecret: "Ate343_9347lajF", // Only necessary for Android
|
||||
disableBackup: true, // Only for Android(optional)
|
||||
localizedFallbackTitle: this.ts.trPK("general", "use-pin"), // Only for iOS
|
||||
localizedReason: this.ts.trPK("general", "auth-please") // Only for iOS
|
||||
})
|
||||
.then((result: any) => {
|
||||
console.log("1");
|
||||
// this.deviceToken= this.cs.sharedService.getSharedData(AuthenticationService.DEVICE_TOKEN, false);
|
||||
let request = new GetLoginInfoRequest();
|
||||
this.authService.setPublicFields(request);
|
||||
request.MobileNumber = this.loginData.MobileNumber;
|
||||
request.P_USER_NAME=this.loginData.P_USER_NAME;
|
||||
request.UserName=this.loginData.P_USER_NAME;
|
||||
request.LogInTokenID =this.loginData.LogInTokenID;
|
||||
request.CompanyID =1;//cs=1 , HMG=2
|
||||
request.DeviceType= this.cs.getDeviceType();
|
||||
request.DeviceToken=this.deviceToken;
|
||||
|
||||
this.getMobileInfo(request);
|
||||
})
|
||||
.catch((error: any) => {
|
||||
console.log(error);
|
||||
});
|
||||
}
|
||||
|
||||
private getMobileInfo(request: GetLoginInfoRequest) {
|
||||
console.log("2");
|
||||
|
||||
this.authService.getLoginInfo(request,() => { },this.ts.trPK("general", "ok")).subscribe((result: GetLoginInfoResponse) => {
|
||||
console.log("authService.getLoginInfo");
|
||||
if(result.Mohemm_GetPatientID_List.length > 0){
|
||||
if ( result.Mohemm_GetPatientID_List[0].LoginType == 2 || result.Mohemm_GetPatientID_List[0].LoginType == 3) {
|
||||
this.loginTokenID = result.LogInTokenID;
|
||||
this.checkSMS();
|
||||
} else {
|
||||
|
||||
this.onlySMSBox = false;
|
||||
this.button();
|
||||
}
|
||||
}else {
|
||||
this.onlySMSBox = false;
|
||||
this.button();
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public checkSMS() {
|
||||
const data = this.sharedData.getSharedData(AuthenticationService.LOGIN_DATA, false);
|
||||
const request = new SMSCheckRequest();
|
||||
|
||||
request.LogInTokenID = data.LogInTokenID;
|
||||
request.activationCode = "";
|
||||
request.P_USER_NAME = data.P_USER_NAME;
|
||||
request.MobileNumber = data.MobileNumber;
|
||||
|
||||
this.authService
|
||||
.checkSMS(request, () => {}, this.ts.trPK("general", "ok"))
|
||||
.subscribe((result: SMSCheckResponse) => {
|
||||
console.log(result);
|
||||
if (this.cs.validResponse(result)) {
|
||||
AuthenticationService.servicePrivilage=result.Privilege_List;
|
||||
this.authService.setAuthenticatedUser(result).subscribe(() => {
|
||||
this.insertMobileLogin();
|
||||
this.cs.openHome();
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
public insertMobileLogin(){
|
||||
let request = new GetLoginInfoRequest();
|
||||
this.authService.setPublicFields(request);
|
||||
request.MobileNumber = this.loginData.MobileNumber;
|
||||
request.P_USER_NAME=this.loginData.P_USER_NAME;
|
||||
request.UserName=this.loginData.P_USER_NAME;
|
||||
request.LogInTokenID =this.loginData.LogInTokenID;
|
||||
request.CompanyID =1;//CompanyID
|
||||
request.DeviceType= this.cs.getDeviceType();
|
||||
request.DeviceToken=this.deviceToken;
|
||||
//request.TokenID=
|
||||
request.LoginType=this.selectedOption;
|
||||
|
||||
this.authService
|
||||
.insertMobileLoginInfo(
|
||||
request,
|
||||
() => { },
|
||||
this.ts.trPK("general", "ok")
|
||||
)
|
||||
.subscribe((result: any) => {
|
||||
console.log(result);
|
||||
|
||||
console.log("succssful insertMobileLoginInfo" );
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,34 @@
|
||||
import { Request } from 'src/app/hmg-common/services/models/request';
|
||||
|
||||
export class SendActivationByType extends Request {
|
||||
P_USER_NAME: string; // id
|
||||
UserName:string;
|
||||
MobileNumber: string; // phone number
|
||||
ZipCode: string;
|
||||
LogInTokenID: string;
|
||||
OTP_SendType:number;
|
||||
IsMobileFingerPrint:number;
|
||||
P_LEGISLATION_CODE:string;
|
||||
// VersionID:string;
|
||||
|
||||
|
||||
|
||||
// Test
|
||||
//{
|
||||
// "Channel":31,
|
||||
// "LanguageID":2,
|
||||
// "LogInTokenID":"Wfm9uDlWhEi3vFsQMqUz3w==",
|
||||
// "MobileNumber":"0508079569",
|
||||
// "P_USER_NAME":"191817",
|
||||
// "UserName":"191817",
|
||||
// "VersionID":2.0,
|
||||
// "P_LEGISLATION_CODE":"SA",
|
||||
// "IsMobileFingerPrint":0,
|
||||
// "OTP_SendType":1
|
||||
// }
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 3.4 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 3.9 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 2.3 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 4.9 KiB |
Loading…
Reference in New Issue