From 4059995a9f12e038e5ee75a7dc299972df4de305 Mon Sep 17 00:00:00 2001 From: "SANDHYA.JS" Date: Thu, 12 Oct 2023 11:29:52 +0530 Subject: [PATCH] Fix Bug 2293: Password Expiry and Account Expiry Time Issue for today & tomorrow scenarios - For today & tomorrow used Math.round - For more than one day concept used Math.floor Change-Id: Ifcc08ae030a7643b3ed0306867513065b06c2007 Signed-off-by: SANDHYA.JS --- src/app/login/LoginComponent.ts | 64 ++++++++++++++++++--------------- src/services/SharedService.ts | 8 +++-- 2 files changed, 42 insertions(+), 30 deletions(-) diff --git a/src/app/login/LoginComponent.ts b/src/app/login/LoginComponent.ts index 964394d..45573e2 100644 --- a/src/app/login/LoginComponent.ts +++ b/src/app/login/LoginComponent.ts @@ -326,24 +326,28 @@ export class LoginComponent implements OnInit { this.sharedService.passwordToaster(this.lastLogin, this.failedAttempts, this.passwordNoOfDays, this.passwordExpireMessage, this.passwordMessage); } else { - if (this.accountNoOfDays === '1') { - this.accountExpireMessage = this.translateService.instant('PAGE.LOGIN.ACCOUNTEXPIRETOMORROW'); - this.accountMessage = ''; - this.accountNoOfDays = ''; - } else if (this.accountNoOfDays === '0') { - this.accountExpireMessage = this.translateService.instant('PAGE.LOGIN.ACCOUNTEXPIRETODAY'); - this.accountMessage = ''; - this.accountNoOfDays = ''; - } else { - this.accountExpireMessage = this.accountExpireMessage = this.translateService.instant('PAGE.LOGIN.ACCOUNTEXPIRE'); - this.accountMessage = this.translateService.instant('PAGE.LOGIN.DAYS'); - } - this.sharedService.showToaster(this.lastLogin, this.failedAttempts, this.passwordNoOfDays, this.accountNoOfDays, - this.passwordExpireMessage, this.accountExpireMessage, this.passwordMessage, this.accountMessage); + this.accountDaysCheck(); } } } } + /** To check account no.of days with 0 & 1 @public */ + public accountDaysCheck(): void { + if (this.accountNoOfDays === '1') { + this.accountExpireMessage = this.translateService.instant('PAGE.LOGIN.ACCOUNTEXPIRETOMORROW'); + this.accountMessage = ''; + this.accountNoOfDays = ''; + } else if (this.accountNoOfDays === '0') { + this.accountExpireMessage = this.translateService.instant('PAGE.LOGIN.ACCOUNTEXPIRETODAY'); + this.accountMessage = ''; + this.accountNoOfDays = ''; + } else { + this.accountExpireMessage = this.accountExpireMessage = this.translateService.instant('PAGE.LOGIN.ACCOUNTEXPIRE'); + this.accountMessage = this.translateService.instant('PAGE.LOGIN.DAYS'); + } + this.sharedService.showToaster(this.lastLogin, this.failedAttempts, this.passwordNoOfDays, this.accountNoOfDays, + this.passwordExpireMessage, this.accountExpireMessage, this.passwordMessage, this.accountMessage); + } /** To display account expiry Toaster with required data @public */ public accountExpiryToaster(): void { if (!isNullOrUndefined(this.accountNoOfDays)) { @@ -364,24 +368,28 @@ export class LoginComponent implements OnInit { this.sharedService.accountToaster(this.lastLogin, this.failedAttempts, this.accountNoOfDays, this.accountExpireMessage, this.accountMessage); } else { - if (this.passwordNoOfDays === '1') { - this.passwordExpireMessage = this.translateService.instant('PAGE.LOGIN.PASSWORDEXPIRETOMORROW'); - this.passwordMessage = ''; - this.passwordNoOfDays = ''; - } else if (this.passwordNoOfDays === '0') { - this.passwordExpireMessage = this.translateService.instant('PAGE.LOGIN.PASSWORDEXPIRETODAY'); - this.passwordMessage = ''; - this.passwordNoOfDays = ''; - } else { - this.passwordExpireMessage = this.translateService.instant('PAGE.LOGIN.PASSWORDEXPIRE'); - this.passwordMessage = this.translateService.instant('PAGE.LOGIN.DAYS'); - } - this.sharedService.showToaster(this.lastLogin, this.failedAttempts, this.passwordNoOfDays, this.accountNoOfDays, - this.passwordExpireMessage, this.accountExpireMessage, this.passwordMessage, this.accountMessage); + this.passwordDaysCheck(); } } } } + /** To check password no.of days with 0 & 1 @public */ + public passwordDaysCheck(): void { + if (this.passwordNoOfDays === '1') { + this.passwordExpireMessage = this.translateService.instant('PAGE.LOGIN.PASSWORDEXPIRETOMORROW'); + this.passwordMessage = ''; + this.passwordNoOfDays = ''; + } else if (this.passwordNoOfDays === '0') { + this.passwordExpireMessage = this.translateService.instant('PAGE.LOGIN.PASSWORDEXPIRETODAY'); + this.passwordMessage = ''; + this.passwordNoOfDays = ''; + } else { + this.passwordExpireMessage = this.translateService.instant('PAGE.LOGIN.PASSWORDEXPIRE'); + this.passwordMessage = this.translateService.instant('PAGE.LOGIN.DAYS'); + } + this.sharedService.showToaster(this.lastLogin, this.failedAttempts, this.passwordNoOfDays, this.accountNoOfDays, + this.passwordExpireMessage, this.accountExpireMessage, this.passwordMessage, this.accountMessage); + } /** To display password & account expiry Toaster with required data @public */ public showToaster(): void { if (!isNullOrUndefined(this.accountNoOfDays) && !isNullOrUndefined(this.passwordNoOfDays)) { diff --git a/src/services/SharedService.ts b/src/services/SharedService.ts index f80eb7c..e8eac94 100644 --- a/src/services/SharedService.ts +++ b/src/services/SharedService.ts @@ -191,8 +191,12 @@ export class SharedService { if (!isNullOrUndefined(date)) { const today: Date = new Date(); const accountDate: Date = new Date(date); - return Math.floor((accountDate.getTime() - - today.getTime()) / this.epochTime1000 / this.epochTime60 / this.epochTime60 / this.epochTime24); + const toasterDate: number = (accountDate.getTime() - + today.getTime()) / this.epochTime1000 / this.epochTime60 / this.epochTime60 / this.epochTime24; + if (toasterDate >= 0 || toasterDate < 1) { + return Math.round(toasterDate); + } + return Math.floor(toasterDate); } return this.translateService.instant('N/A'); } -- 2.25.1