From c05f5c47259efa148916443524fd4122e1d48c55 Mon Sep 17 00:00:00 2001 From: enadhilal Date: Mon, 7 Feb 2022 17:05:07 +0300 Subject: [PATCH] added validation to forget password component --- .../forgot/forgot.component.html | 37 +++- .../authentication/forgot/forgot.component.ts | 158 ++++++++++++++++-- .../services/connector/connector.service.ts | 4 +- .../service/work-list.main.service.ts | 16 ++ .../worklist-main/worklist-main.component.ts | 16 ++ 5 files changed, 216 insertions(+), 15 deletions(-) diff --git a/Mohem/src/app/authentication/forgot/forgot.component.html b/Mohem/src/app/authentication/forgot/forgot.component.html index f363261d..91bb43a6 100644 --- a/Mohem/src/app/authentication/forgot/forgot.component.html +++ b/Mohem/src/app/authentication/forgot/forgot.component.html @@ -37,6 +37,39 @@ [(ngModel)]="P_Confirm_NEW_PASSWORD"> + + + +

{{recentPasswordNote.text}}

+
+ + +

{{isLowerCase.text}}

+
+ + +

{{isUpperCase.text}}

+
+ + +

{{isHasDigit.text}}

+
+ + +

{{isMinLength.text}}

+
+ + +

{{isRepeatedLetter.text}}

+
+ + +

{{isContainSpecialChar.text}}

+
+ + +

{{confirmMatchNew.text}}

+
@@ -45,6 +78,8 @@
- +
\ No newline at end of file diff --git a/Mohem/src/app/authentication/forgot/forgot.component.ts b/Mohem/src/app/authentication/forgot/forgot.component.ts index 8e76d97a..c9688ec5 100644 --- a/Mohem/src/app/authentication/forgot/forgot.component.ts +++ b/Mohem/src/app/authentication/forgot/forgot.component.ts @@ -9,7 +9,7 @@ import { SmsReaderService } from 'src/app/hmg-common/services/sms/sms-reader.ser import { ForgetPassword } from '../models/forget.password'; import { LoginModel } from '../models/LoginModel'; import { SharedDataService } from 'src/app/hmg-common/services/shared-data-service/shared-data.service'; -import {LoginComponent} from "src/app/authentication/login/login.component"; +import { LoginComponent } from "src/app/authentication/login/login.component"; @Component({ selector: 'app-forgot', templateUrl: './forgot.component.html', @@ -18,10 +18,56 @@ import {LoginComponent} from "src/app/authentication/login/login.component"; export class ForgotComponent implements OnInit { private loginData = new LoginModel(); - public P_NEW_PASSWORD: string; - public P_Confirm_NEW_PASSWORD : string; - public P_USER_NAME : string; + public P_NEW_PASSWORD: string = ''; + public P_Confirm_NEW_PASSWORD: string = ''; + public P_USER_NAME: string; public logo = "assets/icon/login/lock.png"; + public recentPasswordNote = { + yellowImg: '../assets/icon/yellow.svg', + text: 'Do not user recent password' + }; + public isLowerCase = { + blankImg: '../assets/icon/blank.svg', + greenImg: '../assets/icon/green.svg', + text: 'At least one lowercase', + isMatch: false + }; + public isUpperCase = { + blankImg: '../assets/icon/blank.svg', + greenImg: '../assets/icon/green.svg', + text: 'At least one uppdercase', + isMatch: false + }; + public isHasDigit = { + blankImg: '../assets/icon/blank.svg', + greenImg: '../assets/icon/green.svg', + text: 'At least one nomeric', + isMatch: false + }; + public isMinLength = { + blankImg: '../assets/icon/blank.svg', + greenImg: '../assets/icon/green.svg', + text: 'Minimum 8 characters', + isMatch: false + }; + public isRepeatedLetter = { + blankImg: '../assets/icon/blank.svg', + greenImg: '../assets/icon/green.svg', + text: 'Do not add repeating letters', + isMatch: false + }; + public isContainSpecialChar = { + blankImg: '../assets/icon/blank.svg', + greenImg: '../assets/icon/green.svg', + text: 'It should contain special character', + isMatch: false + }; + public confirmMatchNew = { + blankImg: '../assets/icon/blank.svg', + greenImg: '../assets/icon/green.svg', + text: 'Confirm Password does not match.', + isMatch: false + }; constructor( public cs: CommonService, @@ -35,7 +81,7 @@ export class ForgotComponent implements OnInit { ) { } - ngOnInit() {} + ngOnInit() { } public onForgot() { this.sendSMSForForgotPassword(); @@ -56,7 +102,7 @@ export class ForgotComponent implements OnInit { }); } - public forgotpassword(){ + public forgotpassword() { const data = this.sharedData.getSharedData(AuthenticationService.LOGIN_DATA, false); const forgetPasswordTokenResult = this.sharedData.getSharedData('checkSMSResponse', false); let forgetPasswordTokenID = ''; @@ -65,11 +111,11 @@ export class ForgotComponent implements OnInit { } this.loginData.P_USER_NAME = this.P_USER_NAME; let request: any = {}; - request.P_Confirm_NEW_PASSWORD=this.P_NEW_PASSWORD; - request.P_NEW_PASSWORD=this.P_Confirm_NEW_PASSWORD; + request.P_Confirm_NEW_PASSWORD = this.P_NEW_PASSWORD; + request.P_NEW_PASSWORD = this.P_Confirm_NEW_PASSWORD; request.P_USER_NAME = data.P_USER_NAME; - request.ForgetPasswordTokenID = forgetPasswordTokenID; - + request.ForgetPasswordTokenID = forgetPasswordTokenID; + this.authService.submitForgetPassword( request, () => { @@ -78,10 +124,98 @@ export class ForgotComponent implements OnInit { if (this.cs.validResponse(result)) { this.checkUserResult = result; console.log(result); - this.cs.toastPK("changePassword","successChange"); + this.cs.toastPK("changePassword", "successChange"); this.cs.openLogin(); } }); - + + } + + checkerFuncation(val) { + if (this.P_NEW_PASSWORD === '') { + switch (val) { + case 1: + return this.isLowerCase.blankImg; + case 2: + return this.isUpperCase.blankImg; + case 3: + return this.isHasDigit.blankImg; + case 4: + return this.isMinLength.blankImg; + case 5: + return this.isRepeatedLetter.blankImg; + case 6: + return this.isContainSpecialChar.blankImg; + case 7: + return this.confirmMatchNew.blankImg; + } + } else { + switch (val) { + case 1: + if (/[a-z]/.test(this.P_NEW_PASSWORD)) { + this.isLowerCase.isMatch = true; + return this.isLowerCase.greenImg; + } else { + this.isLowerCase.isMatch = false; + return this.isLowerCase.blankImg; + } + case 2: + if (/[A-Z]/.test(this.P_NEW_PASSWORD)) { + this.isUpperCase.isMatch = true; + return this.isUpperCase.greenImg; + } else { + this.isUpperCase.isMatch = false; + return this.isUpperCase.blankImg; + } + case 3: + if (/[0-9]/.test(this.P_NEW_PASSWORD)) { + this.isHasDigit.isMatch = true; + return this.isHasDigit.greenImg; + } else { + this.isHasDigit.isMatch = false; + return this.isHasDigit.blankImg; + } + case 4: + if (this.P_NEW_PASSWORD.length >= 8) { + this.isMinLength.isMatch = true; + return this.isMinLength.greenImg; + } else { + this.isMinLength.isMatch = false; + return this.isMinLength.blankImg; + } + case 5: + if (/([a-z])\1/i.test(this.P_NEW_PASSWORD)) { + this.isRepeatedLetter.isMatch = false; + return this.isRepeatedLetter.blankImg; + } else { + this.isRepeatedLetter.isMatch = true; + return this.isRepeatedLetter.greenImg; + } + case 6: + if (/[ `!@#$%^&*()_+\-=\[\]{};':"\\|,.<>\/?~]/.test(this.P_NEW_PASSWORD)) { + this.isContainSpecialChar.isMatch = true; + return this.isContainSpecialChar.greenImg; + } else { + this.isContainSpecialChar.isMatch = false; + return this.isContainSpecialChar.blankImg; + } + case 7: + if (this.P_NEW_PASSWORD !== this.P_Confirm_NEW_PASSWORD) { + this.confirmMatchNew.isMatch = true; + return this.confirmMatchNew.blankImg; + } else { + this.confirmMatchNew.isMatch = false; + return this.confirmMatchNew.greenImg; + } + } + } } + + disabledSubmitBtn() { + if (this.isLowerCase.isMatch && this.isUpperCase.isMatch && this.isHasDigit.isMatch && this.isMinLength.isMatch + && this.isRepeatedLetter.isMatch && this.P_NEW_PASSWORD !== '' && this.P_NEW_PASSWORD + && this.P_Confirm_NEW_PASSWORD && this.isContainSpecialChar) { + return false; + } else { return true; } + } } 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 70a9d157..62631565 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, diff --git a/Mohem/src/app/notification/service/work-list.main.service.ts b/Mohem/src/app/notification/service/work-list.main.service.ts index d83f642e..16d503a2 100644 --- a/Mohem/src/app/notification/service/work-list.main.service.ts +++ b/Mohem/src/app/notification/service/work-list.main.service.ts @@ -37,6 +37,7 @@ export class WorklistMainService { public static getStampMSNotificationBody = "Services/ERP.svc/REST/GET_STAMP_MS_NOTIFICATION_BODY"; public static getStampNSNotificationBody = "Services/ERP.svc/REST/GET_STAMP_NS_NOTIFICATION_BODY"; public static getAddressNotificationBody = "Services/ERP.svc/REST/GET_ADDRESS_NOTIFICATION_BODY"; + public static getCEINotificationBody = "Services/ERP.svc/REST/GET_CEI_NOTIFICATION_BODY"; public static getPOItemHistory = "Services/ERP.svc/REST/GET_PO_ITEM_HISTORY"; public static getMOItemHistory = "Services/ERP.svc/REST/GET_MO_ITEM_HISTORY"; public static getNotificationButtons = "Services/ERP.svc/REST/GET_NOTIFICATION_BUTTONS"; @@ -102,6 +103,21 @@ export class WorklistMainService { ); } + public getCEINotificationBody( + WorkListBodyRequest: any, + onError?: any, + errorLabel?: string + ): Observable { + const request = WorkListBodyRequest; + this.authService.authenticateRequest(request); + return this.api.post( + WorklistMainService.getCEINotificationBody, + request, + onError, + errorLabel + ); + } + public getPRNotificationBody( WorkListBodyRequest: any, onError?: any, diff --git a/Mohem/src/app/notification/worklist-main/worklist-main.component.ts b/Mohem/src/app/notification/worklist-main/worklist-main.component.ts index 5fcabd74..61942553 100644 --- a/Mohem/src/app/notification/worklist-main/worklist-main.component.ts +++ b/Mohem/src/app/notification/worklist-main/worklist-main.component.ts @@ -294,6 +294,8 @@ export class WorklistMainComponent implements OnInit { this.getPhoneNotificationDetails(this.WorkListBodyObj); } else if (this.getPassNotificationDetails.REQUEST_TYPE === 'CONTACT') { this.getContactNotificationDetails(this.WorkListBodyObj); + } else if (this.getPassNotificationDetails.REQUEST_TYPE === 'CEI') { + this.getCEINotification(this.WorkListBodyObj); } } @@ -352,6 +354,14 @@ export class WorklistMainComponent implements OnInit { }); } + getCEINotification(notificationBodyObj) { + this.worklistMainService + .getCEINotificationBody(notificationBodyObj) + .subscribe((result: MONotificatonBodyResponse) => { + this.handleWorkListBodyResult(result, "CEI"); + }); + } + getPRNotificationDetails(notificationBodyObj) { this.worklistMainService .getPRNotificationBody(notificationBodyObj) @@ -436,6 +446,12 @@ export class WorklistMainComponent implements OnInit { result.GetBasicDetNtfBodyList; console.log(result); } + } else if (Type === "CEI"){ + if (result.GetCEICollectionNotificationBodyList) { + this.notificationBodyRes = + result.GetCEICollectionNotificationBodyList; + console.log(result); + } } else if (Type === "STAMP_MS"){ if (result.GetStampMsNotificationBodyList) {