fixed timer issue login forgot password disable issue and handled version issue

MOHEMM-Q3-DEV-LATEST
umasoodch 5 years ago
parent ad99cf9a37
commit e4525ea728

@ -32,6 +32,6 @@
</ion-content> </ion-content>
<ion-footer> <ion-footer>
<div class="centerDiv"> <div class="centerDiv">
<ion-button class="button-login" ion-button (click)=" userCheck()">{{ts.trPK('login','changepassword')}}</ion-button> <ion-button [ngClass]="{'disable-button-opacity': isValidForm()}" class="button-login" ion-button (click)=" userCheck()" [disabled]="isValidForm()">{{ts.trPK('login','changepassword')}}</ion-button>
</div> </div>
</ion-footer> </ion-footer>

@ -39,6 +39,13 @@ export class CheckUserComponent implements OnInit {
this.sendSMSForForgotPassword(); this.sendSMSForForgotPassword();
} }
public isValidForm(): boolean {
if (this.P_USER_NAME) {
return false;
}
return true;
}
public userCheck() public userCheck()
{ {
this.cs.startLoading(); this.cs.startLoading();

@ -16,6 +16,7 @@ import { Platform } from '@ionic/angular';
import { CheckUserAuthenticationResponse } from 'src/app/hmg-common/services/authentication/models/check-user-auth.response'; import { CheckUserAuthenticationResponse } from 'src/app/hmg-common/services/authentication/models/check-user-auth.response';
import { LoginModel } from '../models/LoginModel'; import { LoginModel } from '../models/LoginModel';
import * as moment from 'moment'; import * as moment from 'moment';
import { CheckAppVersionResponse } from 'src/app/hmg-common/services/authentication/models/check-app-version.response';
@Component({ @Component({
selector: 'app-confirm-login', selector: 'app-confirm-login',
@ -44,6 +45,9 @@ export class ConfirmLoginComponent implements OnInit {
user_name: string; user_name: string;
FFloginType: any; FFloginType: any;
public isPostNoLoad = true; public isPostNoLoad = true;
private iosLink: string;
private androidLink: string;
constructor( constructor(
public ts: TranslatorService, public ts: TranslatorService,
@ -401,17 +405,45 @@ private checkUserAuthentication() {
}); });
} }
private handleAppUpdate(result) {
this.iosLink = result.IOSLink;
this.androidLink = result.AndroidLink;
if (this.platform.is('android')) {
if (this.androidLink) {
window.open(this.androidLink, '_system');
}
} else if (this.platform.is('ios')) {
if (this.iosLink) {
window.open(this.iosLink, '_system');
}
}
}
public checkAppUpdated() {
this.authService.checkApplicationVersion(() => {}).subscribe((result: CheckAppVersionResponse) => {
// tslint:disable-next-line: triple-equals
if (result.MessageStatus == 2 && result.ErrorType == 4) {
this.cs.presentAcceptDialog(result.ErrorEndUserMessage, () => {
this.handleAppUpdate(result);
});
// tslint:disable-next-line: triple-equals
} else if (result.MessageStatus == 1) {
this.checkUserAuthentication();
}
});
}
checkAccess(el: any) { checkAccess(el: any) {
const data = this.sharedData.getSharedData(AuthenticationService.LOGIN_DATA, false); const data = this.sharedData.getSharedData(AuthenticationService.LOGIN_DATA, false);
this.loginType = el; this.loginType = el;
if (this.accessFromOutSide) { if (this.accessFromOutSide) {
this.checkUserAuthentication(); this.checkAppUpdated();
} else { } else {
// tslint:disable-next-line: triple-equals // tslint:disable-next-line: triple-equals
if (!data == undefined ) { if (!data == undefined ) {
this.confirm(this.loginType); this.confirm(this.loginType);
} else { } else {
this.checkUserAuthentication(); this.checkAppUpdated();
} }
} }
} }

@ -1,33 +1,12 @@
<ion-content padding> <ion-content padding>
<ion-grid class="customGrid"> <ion-grid class="customGrid">
<!-- <ion-row>
<ion-col class="colPad">
<img class="centerDiv" src="../assets/imgs/header.png" />
</ion-col>
</ion-row> -->
<ion-row *ngIf="!user"> <ion-row *ngIf="!user">
<div class="content"> <div class="content">
<div class="first-circle"></div> <div class="first-circle"></div>
<div class="middle-circle"></div> <div class="middle-circle"></div>
<div class="last-circle"></div> <div class="last-circle"></div>
</div> </div>
</ion-row> </ion-row>
<!-- <ion-row *ngIf="user ">
<ion-col [size]="4">
<img [src]="logo" class="logo" />
<ion-img class="centerDiv" src="../assets/imgs/CS.png"></ion-img>
</ion-col>
</ion-row> -->
<ion-row> <ion-row>
<ion-col *ngIf="!user"> <ion-col *ngIf="!user">
@ -35,63 +14,43 @@
</ion-col> </ion-col>
</ion-row> </ion-row>
</ion-grid> </ion-grid>
<div *ngIf="!user">
<ion-item class="item-input-login">
<img style="margin: 9px 8px 9px 0 !important;" class="item-icon" src="assets/imgs/username.png" item-start />
<ion-input class="login-input" required type="text" [(ngModel)]="username" placeholder="{{ts.trPK('login','username')}}">
</ion-input>
</ion-item>
<ion-item class="item-input-login">
<img style="margin: 9px 8px 9px 0 !important;" class="item-icon" src="assets/imgs/password.png" item-start />
<ion-input class="login-input" required type="password" [(ngModel)]="password" placeholder="{{ts.trPK('login','password')}}">
</ion-input>
<button ion-button clear class="forgetText" type="button" (click)="forgetPasswordPage()" item-right >
{{ts.trPK('login','forgot-password')}}
</button>
</ion-item>
<!-- <ion-item> <div *ngIf="!user">
<ion-label>{{ts.trPK('login','remeber-me')}}</ion-label> <ion-item class="item-input-login">
<ion-checkbox [(ngModel)]="remeberMe" (ionChange)="addValue($event)" ></ion-checkbox> <img style="margin: 9px 8px 9px 0 !important;" class="item-icon" src="assets/imgs/username.png" item-start />
</ion-item> --> <ion-input class="login-input" required type="text" [(ngModel)]="username" placeholder="{{ts.trPK('login','username')}}">
</ion-input>
<div class="centerDiv signupDiv" *ngIf="isAppleStore==false"> </ion-item>
<a>{{ts.trPK('login','signup')}}</a>
</div> <ion-item class="item-input-login">
<div ng class="gridDiv" aria-disabled="true"> <img style="margin: 9px 8px 9px 0 !important;" class="item-icon" src="assets/imgs/password.png" item-start />
<button class="gridBtn" ion-button (click)="changeLanguage('2')" [ngClass]="{'active':currentLang ==2}">English</button> <ion-input class="login-input" required type="password" [(ngModel)]="password" placeholder="{{ts.trPK('login','password')}}">
<button class="gridBtn arTxt" ion-button (click)="changeLanguage('1')" [ngClass]="{'active':currentLang ==1}">عربي</button> </ion-input>
<!-- <button class="gridBtn" ion-button (click)="changeLanguage()" style="background: #dcdcdc !important;color: #ccc6c6 !important;margin: 1px;width: 49%">English</button> <button ion-button clear class="forgetText" type="button" (click)="forgetPasswordPage()" item-right >
<button class="gridBtn arTxt" ion-button (click)="changeLanguage()" style="background: #dcdcdc !important;color: #ccc6c6 !important;margin: 1px;width: 49%">عربي</button> --> {{ts.trPK('login','forgot-password')}}
</button>
</ion-item>
<div class="centerDiv signupDiv" *ngIf="isAppleStore==false">
<a>{{ts.trPK('login','signup')}}</a>
</div>
<div ng class="gridDiv" aria-disabled="true">
<button class="gridBtn" ion-button (click)="changeLanguage('2')" [ngClass]="{'active':currentLang ==2}">English</button>
<button class="gridBtn arTxt" ion-button (click)="changeLanguage('1')" [ngClass]="{'active':currentLang ==1}">عربي</button>
</div>
</div> </div>
</div>
<!-- div login-->
<!-- <div *ngIf="welcomeBack"> --> <!-- <div *ngIf="welcomeBack"> -->
<welcome-login (onLogin)="login()" (loginWithUser)="loginWithUser()" *ngIf="user "> <welcome-login (onLogin)="login()" (loginWithUser)="loginWithUser()" *ngIf="user ">
</welcome-login> </welcome-login>
<!-- </div> --> <!-- </div> -->
<div class="centerDiv" style="margin-top: 20px !important;"> <div class="centerDiv" style="margin-top: 20px !important;">
<ion-button class="button-login" (click)="onLogin()">{{ts.trPK('login','login')}}</ion-button> <ion-button [ngClass]="{'disable-button-opacity': isValidForm()}" class="button-login" (click)="onLogin()" [disabled]="isValidForm()">{{ts.trPK('login','login')}}</ion-button>
</div> </div>
</ion-content> </ion-content>
<ion-footer *ngIf="!user" [ngStyle]="keyboardOpened === true ? {'display': 'none'} : {}">
<!-- <br /> -->
<!-- <div class="centerDiv">
<a (click)="forgetPasswordPage()">{{ts.trPK('login','forgot-password')}}</a>
</div> -->
<ion-footer *ngIf="!user" [ngStyle]="keyboardOpened === true ? {'display': 'none'} : {}">
<ion-row> <ion-row>
<ion-col class="colPad"> <ion-col class="colPad">
<img class="centerDiv logoFotor" src="../assets/imgs/CSLogo.png" /> <img class="centerDiv logoFotor" src="../assets/imgs/CSLogo.png" />

@ -26,7 +26,6 @@ import { KeyboardStatusModel } from 'src/app/hmg-common/services/keyboard/keyboa
}) })
export class LoginComponent implements OnInit, OnDestroy { export class LoginComponent implements OnInit, OnDestroy {
deviceToken1: any; deviceToken1: any;
constructor( constructor(
public cs: CommonService, public cs: CommonService,
@ -45,7 +44,6 @@ export class LoginComponent implements OnInit, OnDestroy {
public pushService: PushService, public pushService: PushService,
public keyboardService: KeyboardService public keyboardService: KeyboardService
) { ) {
this.events.subscribe('logoutFlage', logoutFlage => { this.events.subscribe('logoutFlage', logoutFlage => {
console.log('login compont logoutFlage: ' + logoutFlage); console.log('login compont logoutFlage: ' + logoutFlage);
// tslint:disable-next-line: triple-equals // tslint:disable-next-line: triple-equals
@ -55,20 +53,18 @@ export class LoginComponent implements OnInit, OnDestroy {
localStorage.setItem('logoutFlage', logoutFlage); localStorage.setItem('logoutFlage', logoutFlage);
} }
}); });
this.getuser = this.cs.sharedService.getSharedData( this.getuser = this.cs.sharedService.getSharedData(
AuthenticationService.IMEI_USER_DATA, AuthenticationService.IMEI_USER_DATA,
false false
); );
// alert(" this.getuser "+this.getuser);
if (this.getuser) { if (this.getuser) {
this.user = true; this.user = true;
} else { } else {
this.user = false; this.user = false;
} }
} }
appLang = 1; appLang = 1;
isExpired = false; isExpired = false;
isSupportAr = false; isSupportAr = false;
@ -99,17 +95,9 @@ export class LoginComponent implements OnInit, OnDestroy {
getuser: any = ''; getuser: any = '';
getlastlogin: any; getlastlogin: any;
public keyboardOpened = false; public keyboardOpened = false;
private checkUserResult: CheckUserAuthenticationResponse; private checkUserResult: CheckUserAuthenticationResponse;
ngOnInit() { ngOnInit() {
// if(!this.cs.getIsTimeSessionOut()){
// this.getlastlogin = this.cs.sharedService.getSharedData(
// AuthenticationService.IMEI_USER_DATA,
// false
// );
// console.log("this.getlastlogin"+ this.getlastlogin);
// }
this.monitorKeyboardChange(); this.monitorKeyboardChange();
this.currentLang = TranslatorService.getCurrentLanguageCode(); this.currentLang = TranslatorService.getCurrentLanguageCode();
console.log(TranslatorService.CURRENT_LANGUAGE) console.log(TranslatorService.CURRENT_LANGUAGE)
@ -121,38 +109,11 @@ export class LoginComponent implements OnInit, OnDestroy {
this.language = "AR"; this.language = "AR";
this.changeLanguage('1') this.changeLanguage('1')
} }
console.log("current lang: "+this.currentLang) console.log("current lang: "+this.currentLang);
//this.ts.switchLanguage();
// this.deviceToken= this.cs.sharedService.getSharedData(AuthenticationService.DEVICE_TOKEN, false);
// console.log("get deviceToken login"+ this.deviceToken)
// this.getuser = this.cs.sharedService.getSharedData(
// AuthenticationService.IMEI_USER_DATA,
// false
// );
// if(this.getuser){
// console.log("this.getuser"+this.getuser);
// this.logoutFlage = true;
// }
this.events.subscribe('user', user => { this.events.subscribe('user', user => {
this.user = user; this.user = user;
}); });
//this.deviceToken = localStorage.getItem('devicyeToken');
//this.deviceToken1 =this.cs.getDeviceToken();
console.log(" this.user login in init" + this.user);
//this.deviceToken = localStorage.getItem('devicyeToken');
this.deviceToken =this.cs.getDeviceToken(); this.deviceToken =this.cs.getDeviceToken();
console.log('lngOnInit localStorage: ' + this.deviceToken1);
console.log('lngOnInit getDeviceToken: ' + this.deviceToken);
if (this.deviceToken) { if (this.deviceToken) {
console.log('login enabled first time: ' + this.deviceToken); console.log('login enabled first time: ' + this.deviceToken);
} else { } else {
@ -160,7 +121,7 @@ export class LoginComponent implements OnInit, OnDestroy {
this.pushService.startReceiving(); this.pushService.startReceiving();
} }
// here will delete below part and depdding on user (response from getMobileInfo) // here will delete below part and depdding on user (response from getMobileInfo)
this.username = localStorage.getItem('user'); this.username = localStorage.getItem('user');
this.password = localStorage.getItem('password'); // ****// this.password = localStorage.getItem('password'); // ****//
const remember = localStorage.getItem('remember'); // ****// const remember = localStorage.getItem('remember'); // ****//
@ -192,6 +153,7 @@ export class LoginComponent implements OnInit, OnDestroy {
} }
this.currentLang = langNumber; this.currentLang = langNumber;
} }
public forgetPasswordPage() { public forgetPasswordPage() {
this.cs.openUserForgot(); this.cs.openUserForgot();
} }
@ -214,12 +176,12 @@ export class LoginComponent implements OnInit, OnDestroy {
} }
public onLogin() { public onLogin() {
this.deviceToken = localStorage.getItem('deviceToken'); this.deviceToken = localStorage.getItem('deviceToken');
if (this.deviceToken) { if (this.deviceToken) {
this.checkAppUpdated(); this.checkAppUpdated();
} else { } else {
this.pushService.startReceiving(); this.pushService.startReceiving();
setTimeout(() => { setTimeout(() => {
this.deviceToken = localStorage.getItem('deviceToken'); this.deviceToken = localStorage.getItem('deviceToken');
this.checkAppUpdated(); this.checkAppUpdated();
console.log('login enabled second time: ' + this.deviceToken); console.log('login enabled second time: ' + this.deviceToken);
@ -228,10 +190,7 @@ export class LoginComponent implements OnInit, OnDestroy {
} }
public checkAppUpdated() { public checkAppUpdated() {
this.authService.checkApplicationVersion( this.authService.checkApplicationVersion(() => {}).subscribe((result: CheckAppVersionResponse) => {
() => {
/* Write code for error */
}).subscribe((result: CheckAppVersionResponse) => {
// tslint:disable-next-line: triple-equals // tslint:disable-next-line: triple-equals
if (result.MessageStatus == 2 && result.ErrorType == 4) { if (result.MessageStatus == 2 && result.ErrorType == 4) {
this.cs.presentAcceptDialog(result.ErrorEndUserMessage, () => { this.cs.presentAcceptDialog(result.ErrorEndUserMessage, () => {
@ -258,12 +217,14 @@ export class LoginComponent implements OnInit, OnDestroy {
} }
} }
private checkUserAuthentication() { public isValidForm(): boolean {
console.log('debug Here!!'); if (this.username && this.password) {
console.log(this.username); return false;
console.log(this.language); }
console.log(this.password); return true;
}
private checkUserAuthentication() {
this.cs.startLoading(); this.cs.startLoading();
const request = new LoginRequest(); const request = new LoginRequest();
request.P_USER_NAME = this.username; request.P_USER_NAME = this.username;
@ -273,16 +234,12 @@ export class LoginComponent implements OnInit, OnDestroy {
this.authService this.authService
.login(request, () => { .login(request, () => {
console.log('error here'); console.log('error here');
// console.log(result.MessageStatus);
// this.sharedData.setSharedData(true, Password.IS_EXPIRED_PSW);
// this.userCheck();
}, this.ts.trPK('general', 'ok')) }, this.ts.trPK('general', 'ok'))
.subscribe((result: CheckUserAuthenticationResponse) => { .subscribe((result: CheckUserAuthenticationResponse) => {
console.log('success'); console.log('success');
this.cs.stopLoading(); this.cs.stopLoading();
if (this.cs.validResponse(result)) { if (this.cs.validResponse(result)) {
// alert("result.MemberLoginList.EMPLOYEE_NAME :" + result.MemberLoginList[0].EMPLOYEE_NAME); // alert("result.MemberLoginList.EMPLOYEE_NAME :" + result.MemberLoginList[0].EMPLOYEE_NAME);
this.loginData.LogInTokenID = result.LogInTokenID; this.loginData.LogInTokenID = result.LogInTokenID;
this.loginData.MobileNumber = result.MemberLoginList.P_MOBILE_NUMBER; this.loginData.MobileNumber = result.MemberLoginList.P_MOBILE_NUMBER;
this.loginData.P_USER_NAME = this.username; this.loginData.P_USER_NAME = this.username;
@ -294,8 +251,6 @@ export class LoginComponent implements OnInit, OnDestroy {
// if(!this.welcomeBack){ // if(!this.welcomeBack){
this.cs.openConfirmLoginPage(); // phase#2 add 4 types for OTP this.cs.openConfirmLoginPage(); // phase#2 add 4 types for OTP
// } // }
} else { } else {
console.log('result.IsPasswordExpired'); console.log('result.IsPasswordExpired');
console.log(result.IsPasswordExpired); console.log(result.IsPasswordExpired);
@ -386,7 +341,6 @@ export class LoginComponent implements OnInit, OnDestroy {
} }
console.log('login emit'); console.log('login emit');
console.log('login'); console.log('login');
// this.checkUserAuthentication();
// this.loginDiv=true; // this.loginDiv=true;
this.user = false; this.user = false;
} }
@ -397,9 +351,6 @@ export class LoginComponent implements OnInit, OnDestroy {
this.cs.openConfirmLoginPage(); this.cs.openConfirmLoginPage();
} }
///
getLastLoginInfo() { getLastLoginInfo() {
this.requestGetLoginInfo = { this.requestGetLoginInfo = {
DeviceType: this.cs.getDeviceType(), // "Android",//this.cs.getDeviceType(), DeviceType: this.cs.getDeviceType(), // "Android",//this.cs.getDeviceType(),
@ -419,7 +370,6 @@ export class LoginComponent implements OnInit, OnDestroy {
} else { } else {
this.user = false; this.user = false;
} }
} }
}); });

@ -24,7 +24,7 @@ import { EmailInput } from "../../ui/email/models/email-input";
import { GetLoginInfoRequest } from "./models/get-login-info.request"; import { GetLoginInfoRequest } from "./models/get-login-info.request";
import { GetLoginInfoResponse } from "./models/get-login-info.response"; import { GetLoginInfoResponse } from "./models/get-login-info.response";
import { analyzeAndValidateNgModules } from "@angular/compiler"; import { analyzeAndValidateNgModules } from "@angular/compiler";
import { Events, MenuController } from "@ionic/angular"; import { Events, MenuController, Platform } from "@ionic/angular";
import { InternationalMobileComponent } from "../../ui/mobile-number/international-mobile/international-mobile.component"; import { InternationalMobileComponent } from "../../ui/mobile-number/international-mobile/international-mobile.component";
import { SMSCheckRequest } from "./models/smscheck.request"; import { SMSCheckRequest } from "./models/smscheck.request";
import { SMSCheckResponse } from "./models/smscheck.response"; import { SMSCheckResponse } from "./models/smscheck.response";
@ -94,6 +94,7 @@ export class AuthenticationService {
// public localNotifications: UserLocalNotificationService, // public localNotifications: UserLocalNotificationService,
private events: Events, private events: Events,
private menu: MenuController, private menu: MenuController,
public platform: Platform
) { } ) { }
public authenticateRequest(request: Request, automaticLogin = true): Request { public authenticateRequest(request: Request, automaticLogin = true): Request {
@ -125,13 +126,19 @@ export class AuthenticationService {
} }
public setPublicFields(request: Request): Request { public setPublicFields(request: Request): Request {
const isAndroid = this.platform.is('android');
const isIOS = this.platform.is('ios');
let mobileType = '';
if (isAndroid) {
mobileType = 'android';
} else if (isIOS) {
mobileType = 'ios';
}
request.VersionID = 2.2; request.VersionID = 2.2;
request.Channel = 31; request.Channel = 31;
request.LanguageID = TranslatorService.getCurrentLanguageCode(); request.LanguageID = TranslatorService.getCurrentLanguageCode();
//request.IPAdress = '10.10.10.10'; request.MobileType = mobileType;
//request.SessionID = "any thing"; // ??? required for not authorized login funny
request.MobileType = "";
//request.isDentalAllowedBackend = false;
return request; return request;
} }
public authenticateAndSetPersonalInformation( public authenticateAndSetPersonalInformation(

@ -63,6 +63,7 @@ export class HomePage implements OnInit {
public isShow = false; public isShow = false;
public showVcationRule = false; public showVcationRule = false;
public isFakeLocationUsed = false; public isFakeLocationUsed = false;
public intervalCountdown: any;
public statsButtons = [ public statsButtons = [
{ {
title: this.ts.trPK('attendance-tracking', 'title'), title: this.ts.trPK('attendance-tracking', 'title'),
@ -129,6 +130,7 @@ export class HomePage implements OnInit {
public vacationRuleIcon: string; public vacationRuleIcon: string;
direction: string; direction: string;
public isPostNoLoad = true; public isPostNoLoad = true;
public locationResponse: any;
constructor( constructor(
public ts: TranslatorService, public ts: TranslatorService,
@ -203,7 +205,7 @@ export class HomePage implements OnInit {
} }
timerTick() { timerTick() {
setTimeout(() => { this.intervalCountdown = setTimeout(() => {
if (!this.runTimer) { if (!this.runTimer) {
return; return;
} }
@ -249,6 +251,7 @@ export class HomePage implements OnInit {
if (this.platform.is('android')) { if (this.platform.is('android')) {
this.backgroundGeolocation.getCurrentLocation({ timeout: 10000, enableHighAccuracy: true, maximumAge: 3000 }).then((resp) => { this.backgroundGeolocation.getCurrentLocation({ timeout: 10000, enableHighAccuracy: true, maximumAge: 3000 }).then((resp) => {
if (resp && (resp.latitude && resp.longitude)) { if (resp && (resp.latitude && resp.longitude)) {
this.locationResponse = resp;
if (resp.isFromMockProvider || resp.mockLocationsEnabled) { if (resp.isFromMockProvider || resp.mockLocationsEnabled) {
this.isFakeLocationUsed = true; this.isFakeLocationUsed = true;
} }
@ -612,6 +615,7 @@ showAttendanceTracking() {
}; };
this.DS.getAttendanceTracking(request, '', '', this.isPostNoLoad).subscribe((result: AttendanceTrackingResponse) => { this.DS.getAttendanceTracking(request, '', '', this.isPostNoLoad).subscribe((result: AttendanceTrackingResponse) => {
if (this.common.validResponse(result)) { if (this.common.validResponse(result)) {
clearTimeout(this.intervalCountdown);
const key = 'GetAttendanceTrackingList'; const key = 'GetAttendanceTrackingList';
this.convertAndAssignTime(result[key]); this.convertAndAssignTime(result[key]);
} }

@ -1529,3 +1529,7 @@ table.monthview-datetable th small {
.alert-wrapper { .alert-wrapper {
min-width: 80% !important;//what ever you like min-width: 80% !important;//what ever you like
} }
.disable-button-opacity {
opacity: .5;
}

Loading…
Cancel
Save