Forgot Password, Login and SMS Reader Updated

production
ansariakhtar 6 years ago
commit a46ebcb357

@ -1,42 +1,33 @@
<ion-header>
<ion-toolbar>
<nav-buttons ></nav-buttons>
<ion-title>{{'login,forgot-password' | translate}}</ion-title>
</ion-toolbar>
<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,forgot-password' | translate}}</ion-title>
</ion-toolbar>
</ion-header>
<ion-content padding>
<ion-grid>
<ion-item>
<img class="item-icon" src="assets/imgs/password.png" item-start />
<ion-label>{{'changePassword.newPassword' | translate}}</ion-label>
<ion-input required type="password"
[(ngModel)]="P_NEW_PASSWORD">
</ion-input>
</ion-item>
<ion-item>
<img class="item-icon" src="assets/imgs/password.png" item-start />
<ion-label>{{'changePassword.confirmPassword' | translate}}</ion-label>
<ion-input required type="password"
[(ngModel)]="P_Confirm_NEW_PASSWORD">
</ion-input>
</ion-item>
<img class="item-icon" src="assets/imgs/username.png" item-start />
<ion-label>{{ts.trPK('login','username')}}</ion-label>
<ion-input required type="text" [(ngModel)]="P_USER_NAME">
</ion-input>
</ion-item>
</ion-grid>
<page-trailer [small]="true"></page-trailer>
<footer>
<ion-grid>
<ion-row class="ion-justify-content-center">
<ion-col [size]="10" [sizeLg]="8" [sizeXl]="6" no-padding>
<ion-button (click)="onForgot()" [disabled]="!isValidForm()" expand="block">
{{'general,submit' | translate}} </ion-button>
</ion-col>
</ion-row>
</ion-grid>
</footer>
</ion-content>
</ion-content>
<ion-footer>
<div class="centerDiv">
<ion-button color="customnavy" ion-button (click)=" userCheck()">{{ts.trPK('login','changepassword')}}</ion-button>
</div>
</ion-footer>

@ -0,0 +1,7 @@
.header-toolbar{
--background: linear-gradient(45deg, #3ac1f1 0%, #19a163 36%, #19a163 59%, #1a586d 100%);
}
.btnBack{
background: transparent;
}

@ -31,8 +31,8 @@
<a (click)="signUp()">{{ts.trPK('login','signup')}}</a>
</div>
<div class="gridDiv">
<button class="gridBtn" ion-button (click)="changeLanguage()">English</button>
<button class="gridBtn arTxt" ion-button (click)="changeLanguage()">عربي</button>
<button class="gridBtn" ion-button (click)="changeLanguage()" [ngClass]="{'active':this.currentLang ==1}">English</button>
<button class="gridBtn arTxt" ion-button (click)="changeLanguage()" [ngClass]="{'active':this.currentLang ==2}">عربي</button>
</div>
</ion-content>

@ -1,11 +1,15 @@
.signupDiv {
font-size: 14px;
}
.customGrid {
margin-bottom: 20px;
}
.gridBtn.active{
background:var(--customnavy) !important;
color:var(--light) !important;
}
.gridDiv{direction: rtl}
.pageTitle {
color: var(--dark);
font-size: 23px;

@ -6,7 +6,6 @@ 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 { CheckActivationCodeResponse } from 'src/app/hmg-common/services/authentication/models/check-activation-code.response';
import { SmsReaderService } from 'src/app/hmg-common/services/sms/sms-reader.service';
import { AuthenticatedUser } from 'src/app/hmg-common/services/authentication/models/authenticated-user';
@ -16,8 +15,8 @@ import { GetLoginInfoRequest } from 'src/app/hmg-common/services/authentication/
import { GetLoginInfoResponse } from 'src/app/hmg-common/services/authentication/models/get-login-info.response';
import { Device } from '@ionic-native/device/ngx';
import { SplashScreen } from '@ionic-native/splash-screen/ngx';
import { CountryCode } from 'src/app/hmg-common/ui/mobile-number/international-mobile/models/country-code.model';
import { SMSService } from 'src/app/hmg-common/ui/sms/service/smsservice';
import { SharedDataService } from 'src/app/hmg-common/services/shared-data-service/shared-data.service';
import { LoginModel } from '../models/LoginModel';
@Component({
selector: 'login',
@ -36,6 +35,12 @@ export class LoginComponent implements OnInit, OnDestroy {
private language: string;
private username : string;
private currentLang : any;
private patientOutSA: boolean;
private loginTokenID: string;
private isMobileFingerPrint: boolean;
private FingerPrintPatientIdentificationID: string;
private loginData = new LoginModel();
constructor(
public cs: CommonService,
public authService: AuthenticationService,
@ -46,7 +51,8 @@ export class LoginComponent implements OnInit, OnDestroy {
private faio: FingerprintAIO,
public ngZone: NgZone,
public device: Device,
public splash: SplashScreen
public splash: SplashScreen,
public sharedData: SharedDataService
) {
}
@ -56,6 +62,7 @@ export class LoginComponent implements OnInit, OnDestroy {
this.checkIfLoggedInBefore();
// this.splash.hide();
}, 100);
this.currentLang = TranslatorService.getCurrentLanguageCode();
}
ngOnDestroy(): void {
@ -71,6 +78,8 @@ export class LoginComponent implements OnInit, OnDestroy {
else{
this.language = "AR";
}
this.currentLang = TranslatorService.getCurrentLanguageCode();
console.log(this.currentLang);
}
private checkIfLoggedInBefore() {
this.cs.startLoading();
@ -357,18 +366,10 @@ export class LoginComponent implements OnInit, OnDestroy {
() => {
}, this.ts.trPK('general', 'ok')).subscribe((result: CheckUserAuthenticationResponse) => {
if (this.cs.validResponse(result)) {
console.log(result);
console.log(result);
this.loginData.LogInTokenID = result.LogInTokenID;
this.sharedData.setSharedData(this.loginData, "logindata");
this.cs.openSMSPage();
this.loginTokenID = result.LogInTokenID;
this.patientOutSA = result.PatientOutSA;
this.isMobileFingerPrint = false;
this.FingerPrintPatientIdentificationID = '';
if (result.isSMSSent) {
this.startListeneingForSMS();
} else {
this.smsService.stopSMSMonitoring();
this.checkActivationCode();
}
}
});
}
@ -397,11 +398,6 @@ export class LoginComponent implements OnInit, OnDestroy {
}, null, title);
}
private patientOutSA: boolean;
private loginTokenID: string;
private isMobileFingerPrint: boolean;
private FingerPrintPatientIdentificationID: string;
private checkActivationCode(readedCode?) {
/*const request = new CheckActivationCodeRequest();
request.IsMobileFingerPrint = this.isMobileFingerPrint;
@ -445,7 +441,7 @@ export class LoginComponent implements OnInit, OnDestroy {
if (this.authService.isAgreedBefore()) {
this.cs.openHome();
} else {
//this.cs.openAgreement();
// this.cs.openAgreement();
}
});
}

@ -0,0 +1,6 @@
export class LoginModel {
LogInTokenID: string;
activationCode: string;
P_USER_NAME: string;
MobileNumber: string;
}

@ -9,7 +9,7 @@ import { SmsPagePage } from './sms-page.page';
const routes: Routes = [
{
path: 'smspage',
path: '',
component: SmsPagePage
}
];

@ -1,7 +1,10 @@
<ion-header>
<ion-toolbar>
<ion-title>{{'verificationcode.verificationcode' | translate}}</ion-title>
</ion-toolbar>
<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" > {{'verificationcode,verificationcode' | translate}}</ion-title>
</ion-toolbar>
</ion-header>
<ion-content padding>
@ -13,7 +16,7 @@
</ion-row>
<ion-row>
<ion-col>
<p class="centerDiv">{{'verificationcode.title' | translate}}<span class="boldTxtNav">{{'verificationcode.verificationcode' | translate}}</span> {{'verificationcode.by' | translate}}<span class="boldTxtNav">{{'verificationcode.sms' | translate}}</span>{{'verificationcode.instruct' | translate}}<span class="boldTxtNav">{{'general.submit' | translate}}</span></p>
<p class="centerDiv">{{'verificationcode,title' | translate}}<span class="boldTxtNav">{{'verificationcode,verificationcode' | translate}}</span> {{'verificationcode,by' | translate}}<span class="boldTxtNav">{{'verificationcode,sms' | translate}}</span>{{'verificationcode,instruct' | translate}}<span class="boldTxtNav">{{'general,submit' | translate}}</span></p>
</ion-col>
</ion-row>
</ion-grid>
@ -23,7 +26,7 @@
<h1 text-center>{{displayTime}}</h1>
<br/><br/>
<ion-item>
<ion-label>{{'verificationcode.verificationcode' | translate}}</ion-label>
<ion-label>{{'verificationcode,verificationcode' | translate}}</ion-label>
<!-- <img class="item-icon" src="assets/imgs/password.png" item-start /> -->
<ion-input required type="tel" [(ngModel)]="activationCode"></ion-input>
</ion-item>
@ -31,6 +34,6 @@
</ion-content>
<ion-footer>
<div class="centerDiv">
<button ion-button (click)="checkVerificationCode()">{{'general.submit' | translate}}</button>
<ion-button color="customnavy" ion-button (click)="checkVerificationCode()">{{'general,submit' | translate}}</ion-button>
</div>
</ion-footer>

@ -0,0 +1,21 @@
.header-toolbar{
--background: linear-gradient(45deg, #3ac1f1 0%, #19a163 36%, #19a163 59%, #1a586d 100%);
}
.btnBack{
background: transparent;
}
ion-img{
width: 180px;
height: 180px;
background:transparent;
}
h1{
font-size: 28px !important;
}
span{
font-weight: bold;
}

@ -1,9 +1,15 @@
import { Component, OnInit } from '@angular/core';
import { ElementRef} 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';
import { SMSCheckRequest } from 'src/app/hmg-common/services/authentication/models/smscheck.request';
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';
@Component({
selector: 'app-sms-page',
templateUrl: './sms-page.page.html',
@ -11,28 +17,133 @@ import { SharedDataService } from 'src/app/hmg-common/services/shared-data-servi
})
export class SmsPagePage implements OnInit {
Channel: number=0;
Channel: number = 0;
activationCode: string;
P_SESSION_ID: number;
P_SESSION_ID: number;
timeInSeconds: any;
time:any;
runTimer: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;
remainingTime: any;
displayTime: any;
loginTokenID: string;
public isForgetPwd: boolean = false;
public isExpiredPwd: boolean = false;
public count: number = 0;
private loginData = new LoginModel();
constructor(public navCtrl: NavController,
public translate: TranslatorService,
public common:CommonService,
private elementRef:ElementRef,
public sharedData:SharedDataService) { }
public common: CommonService,
private elementRef: ElementRef,
public authService: AuthenticationService,
public sharedData: SharedDataService) { }
ngOnInit() {
this.count = 0;
this.initTimer();
this.startTimer();
}
initTimer() {
// Pomodoro is usually for 25 minutes
if (!this.timeInSeconds) {
this.timeInSeconds = 600;
}
this.time = this.timeInSeconds;
this.runTimer = false;
this.hasStarted = false;
this.hasFinished = false;
this.remainingTime = this.timeInSeconds;
this.displayTime = this.common.getSecondsAsDigitalClock(this.remainingTime);
}
startTimer() {
this.runTimer = true;
this.hasStarted = true;
this.timerTick();
}
pauseTimer() {
this.runTimer = false;
}
resumeTimer() {
this.startTimer();
}
timerTick() {
setTimeout(() => {
if (!this.runTimer) { return; }
this.remainingTime--;
this.displayTime = this.common.getSecondsAsDigitalClock(this.remainingTime);
if (this.remainingTime > 0) {
this.timerTick();
}
else {
this.hasFinished = true;
this.pauseTimer();
this.navCtrl.pop();
}
}, 1000);
}
ionViewWillLeave() {
this.pauseTimer();
}
checkVerificationCode() {
if (this.count < 3) {
if (this.activationCode == undefined || this.activationCode == null || this.activationCode == "") {
// this.common.showAlert(this.translate.translate('verificationcode.emptyCode'));
} else {
this.count = this.count + 1;
if (this.isForgetPwd || this.isExpiredPwd) {
this.checkForgetPwdSMS();
} else {
this.checkSMS();
}
}
} else {
let msg: string = this.translate.trPK('general', 'noOfTriesLogin');
//this.common.showAlert(msg);
//this.navCtrl.pop(); goBack
this.common.JustAlertDialog(this.translate.trPK("general", "ok"), msg);
}
}
public checkSMS()
{
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
this.authService.checkSMS(
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.openHome();
}
});
}
public checkForgetPwdSMS()
{
}
}

@ -24,6 +24,8 @@ import { GetLoginInfoResponse } from './models/get-login-info.response';
import { analyzeAndValidateNgModules } from '@angular/compiler';
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';
@Injectable({
providedIn: 'root'
@ -42,6 +44,10 @@ export class AuthenticationService {
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';
@ -433,6 +439,12 @@ export class AuthenticationService {
return this.con.post(AuthenticationService.activationCodeURL, request, onError, errorLabel);
}
public checkSMS(request: SMSCheckRequest, onError: any, errorLabel: string)
: Observable<SMSCheckResponse> {
this.setPublicFields(request);
return this.con.post(AuthenticationService.smsCheck, request, onError, errorLabel);
}
/*
client side:
id no , mobile no , zip code
@ -568,7 +580,7 @@ export class AuthenticationService {
private sessionTimeOutDialog() {
this.cs.presentConfirmDialog(this.ts.trPK('general', 'idle-relogin'), () => {
//this.cs.openUserLogin();
// this.cs.openUserLogin();
});
}

@ -0,0 +1,6 @@
import { Request } from '../../models/request';
export class SMSCheckRequest extends Request {
LogInTokenID?: string ;
activationCode?: string;
}

@ -0,0 +1,7 @@
import { Response } from '../../models/response';
import { AuthenticatedUser } from './authenticated-user';
export class SMSCheckResponse extends Response {
AuthenticationTokenID: string;
PatientOutSA: boolean;
PatientType: number;
}

@ -120,6 +120,21 @@ export class CommonService {
}
}
getSecondsAsDigitalClock(inputSeconds: number) {
var sec_num = parseInt(inputSeconds.toString(), 10); // don't forget the second param
var hours = Math.floor(sec_num / 3600);
var minutes = Math.floor((sec_num - (hours * 3600)) / 60);
var seconds = sec_num - (hours * 3600) - (minutes * 60);
var hoursString = '';
var minutesString = '';
var secondsString = '';
hoursString = (hours < 10) ? "0" + hours : hours.toString();
minutesString = (minutes < 10) ? "0" + minutes : minutes.toString();
secondsString = (seconds < 10) ? "0" + seconds : seconds.toString();
return minutesString + ':' + secondsString;
}
public toastPK(page: string, key: string) {
this.toast(this.ts.trPK(page, key));
}
@ -255,6 +270,26 @@ export class CommonService {
);
}
async JustAlertDialog(acceptLabel: string,
message: string)
{
this.clearAllAlerts();
const alert = await this.alertControllerIonic.create({
header: this.ts.trPK("general", "info"),
message: message,
buttons: [
{
text: acceptLabel,
handler: () => {
this.alertControllerIonic.dismiss();
}
}
]
});
// this.alerts.push(alert);
await alert.present();
}
async confirmAlertDialog(
onAccept: any,
acceptLabel: string,

@ -37,6 +37,10 @@
"en": "Password",
"ar": "كلمه السر"
},
"changepassword": {
"en": "Change Password",
"ar": "غير كلمة السر"
},
"forgot-your-id": {
"en": "Forgot Your Patient ID",
"ar": "هل نسيت رقم ملف المريض"
@ -80,6 +84,37 @@
"national-id-or-iqama": {
"en": "National ID or Iqama",
"ar": "رقم الهوية أو الإقامة"
},
"sms-page":{
"en": "Verify OTP",
"ar":"تحقق مرة واحدة كلمة المرور"
}
},
"verificationcode":
{
"verificationcode":{
"en":"Verification Code",
"ar":"رمز التحقق"
},
"emptyCode":{
"en":"Please enter the verification code",
"ar":"الرجاء ادخال رمز التحقق"
},
"title":{
"en":"You will receive a ",
"ar":" سوف تستلم "
},
"by":{
"en":" by ",
"ar":"عن طريق "
},
"sms":{
"en":"SMS",
"ar":" رسالة نصية "
},
"instruct":{
"en":" fill the code and ",
"ar":" ادخل الرمز و اضغط "
}
},
"general": {

Loading…
Cancel
Save