diff --git a/Mohem/src/app/authentication/sms-page/sms-page.page.html b/Mohem/src/app/authentication/sms-page/sms-page.page.html index 52bf201e..1fa9de7b 100644 --- a/Mohem/src/app/authentication/sms-page/sms-page.page.html +++ b/Mohem/src/app/authentication/sms-page/sms-page.page.html @@ -58,7 +58,7 @@ - +

{{messageValue}}

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 9d9cab9b..69778fb6 100644 --- a/Mohem/src/app/authentication/sms-page/sms-page.page.ts +++ b/Mohem/src/app/authentication/sms-page/sms-page.page.ts @@ -50,6 +50,8 @@ export class SmsPageComponent implements OnInit { loginType: any; activeType: any; public isNFCAvailable = false; + public showErrorMessage = false; + public messageValue: string; constructor( public navCtrl: NavController, @@ -183,6 +185,7 @@ export class SmsPageComponent implements OnInit { } public checkSMS() { + this.showErrorMessage = false; const data = this.sharedData.getSharedData(AuthenticationService.LOGIN_DATA, false); const request = new SMSCheckRequest(); request.LogInTokenID = data.LogInTokenID; @@ -190,9 +193,8 @@ export class SmsPageComponent implements OnInit { request.P_USER_NAME = data.P_USER_NAME; request.MobileNumber = data.MobileNumber; request.IsDeviceNFC = this.isNFCAvailable; - this.authService.checkSMS(request, () => {}, this.translate.trPK('general', 'ok')).subscribe((result: SMSCheckResponse) => { - if (this.common.validResponse(result)) { - + this.authService.checkSMS(request, () => {}, this.translate.trPK('general', 'ok'), true).subscribe((result: SMSCheckResponse) => { + if (this.common.validResponse(result)) { // Wifi Credientials CommonService.MOHEMM_WIFI_SSID = result.Mohemm_Wifi_SSID; CommonService.MOHEMM_WIFI_PASSWORD = result.Mohemm_Wifi_Password; @@ -210,6 +212,16 @@ export class SmsPageComponent implements OnInit { this.activeType =this.common.setActiveTypeLogin(0); this.common.openHome(); }); + } else { + let errorResult: any; + errorResult = result; + this.showErrorMessage = true; + this.messageValue = errorResult.ErrorEndUserMessage; + this.smc_code = []; + (document.activeElement as HTMLElement).blur(); + setTimeout(() => { + this.showErrorMessage = false; + }, 5000); } }); } 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 c8927aa9..09c1e993 100644 --- a/Mohem/src/app/hmg-common/services/authentication/authentication.service.ts +++ b/Mohem/src/app/hmg-common/services/authentication/authentication.service.ts @@ -485,10 +485,10 @@ export class AuthenticationService { return this.con.post(AuthenticationService.activationCodeURL, request, onError, errorLabel); } - public checkSMS(request: SMSCheckRequest, onError: any, errorLabel: string) + public checkSMS(request: SMSCheckRequest, onError: any, errorLabel: string, fromSMS = false ) : Observable { this.setPublicFields(request); - return this.con.post(AuthenticationService.smsCheck, request, onError, errorLabel); + return this.con.post(AuthenticationService.smsCheck, request, onError, errorLabel, fromSMS); } public checkForgetSMS(request: SMSCheckRequest, onError: any, errorLabel: string) diff --git a/Mohem/src/app/hmg-common/services/connector/connector.service.ts b/Mohem/src/app/hmg-common/services/connector/connector.service.ts index 352d691d..ddd23f6d 100644 --- a/Mohem/src/app/hmg-common/services/connector/connector.service.ts +++ b/Mohem/src/app/hmg-common/services/connector/connector.service.ts @@ -27,8 +27,8 @@ export class ConnectorService { public static retryTimes = 0; public static timeOut = 120 * 1000; - // public static host = 'https://uat.hmgwebservices.com/'; - public static host = 'https://hmgwebservices.com/'; + public static host = 'https://uat.hmgwebservices.com/'; + // public static host = 'https://hmgwebservices.com/'; constructor(public httpClient: HttpClient, public cs: CommonService, @@ -39,7 +39,8 @@ export class ConnectorService { service: string, data: any, onError: any, - errorLabel?: string + errorLabel?: string, + fromSMS = false ): Observable { this.cs.startLoading(); return this.httpClient @@ -52,7 +53,7 @@ export class ConnectorService { timeout(ConnectorService.timeOut), retry(ConnectorService.retryTimes), tap( - res => this.handleResponse(res, onError, errorLabel), + res => this.handleResponse(res, onError, errorLabel, false, fromSMS), error => this.handleError(error, onError, errorLabel) ) ); @@ -218,7 +219,8 @@ export class ConnectorService { }); } - public handleResponse(result: Response, onError: any, errorLabel: string, isPostNoLoad = false) { + public handleResponse(result: Response, onError: any, errorLabel: string, isPostNoLoad = false, fromSMS = false) { + console.log('fromSMSValue ' + fromSMS) if (!isPostNoLoad) { this.cs.stopLoading(); } @@ -236,11 +238,16 @@ export class ConnectorService { this.cs.stopLoading(); } else { this.cs.stopLoading(); - this.cs.showErrorMessageDialog( - onError, - errorLabel, - result.ErrorEndUserMessage - ); + if (!fromSMS) { + this.cs.showErrorMessageDialog( + onError, + errorLabel, + result.ErrorEndUserMessage + ); + } else { + console.log('its an error from sms') + } + //add flag if user not auth }