diff --git a/src/app/logging/logging.component.ts b/src/app/logging/logging.component.ts index de95ba4..2aa4cd8 100644 --- a/src/app/logging/logging.component.ts +++ b/src/app/logging/logging.component.ts @@ -118,5 +118,6 @@ export class LoggingComponent implements OnInit { exportDataInExcel(){ this.excelExportServic.exportExcel(this.logsList, LOGGING_DETAILS_FILE_NAME) } + } diff --git a/src/app/user-management/change-password/change-password.component.ts b/src/app/user-management/change-password/change-password.component.ts index ecc6ccf..1519114 100644 --- a/src/app/user-management/change-password/change-password.component.ts +++ b/src/app/user-management/change-password/change-password.component.ts @@ -182,7 +182,7 @@ constructor( const payload = this.getFormPayload(); - this.httpURIService.requestPOST(URIKey.CHANGE_PASSWORD_URI, payload) + this.httpURIService.requestPOST(URIKey.FIRST_LOGIN_URI, payload) .subscribe({ next: (response) => { if (!(response instanceof HttpErrorResponse)) { diff --git a/src/app/utils/app.constants.ts b/src/app/utils/app.constants.ts index 9684b7a..77ff20b 100644 --- a/src/app/utils/app.constants.ts +++ b/src/app/utils/app.constants.ts @@ -11,24 +11,35 @@ export const pageSizeOptions = [ ]; export const toDateAfterFromDateValidator: ValidatorFn = ( - group: AbstractControl + control: AbstractControl ): ValidationErrors | null => { - const fromDate = group.get('fromDate')?.value; - const toDate = group.get('toDate')?.value; - const currentDate = new Date().toISOString(); + const from = control.get('fromDate')?.value; + const to = control.get('toDate')?.value; - if (!fromDate || !toDate) { - return null; + if (!from || !to) return null; + + // Normalize to midnight to avoid timezone bugs + const fromDate = new Date(from); + const toDate = new Date(to); + + fromDate.setHours(0, 0, 0, 0); + toDate.setHours(0, 0, 0, 0); + + const today = new Date(); + today.setHours(0, 0, 0, 0); + + // Rule 1: fromDate must be < toDate + if (fromDate >= toDate) { + return { fromDateGreaterThanOrEqualToToDate: true }; } - if(toDate < fromDate) - return { toDateInvalid: true } - else if(toDate >= currentDate) - return { toDateGreaterThanToday: true } - else - return null + // Rule 2: no future dates + if (fromDate > today || toDate > today) { + return { futureDateNotAllowed: true }; + } + return null; }; export const EXCEL_FILE_TYPE = 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=UTF-8'; diff --git a/src/app/utils/uri-enums.ts b/src/app/utils/uri-enums.ts index a003871..7b2bde9 100644 --- a/src/app/utils/uri-enums.ts +++ b/src/app/utils/uri-enums.ts @@ -11,6 +11,7 @@ export enum URIKey { GET_ALL_USER_URI = "GET_ALL_USER_URI", RESET_PASSWORD_URI = "RESET_PASSWORD_URI", CHANGE_PASSWORD_URI = "CHANGE_PASSWORD_URI", + FIRST_LOGIN_URI = "FIRST_LOGIN_URI", THIRD_PARTY_REGISTER_URI = "THIRD_PARTY_REGISTER_URI", TRANSACTION_LOGS = "TRANSACTION_LOGS", LOGGER_MANAGER_URI = "LOGGER_MANAGER_URI" diff --git a/src/assets/data/app.uri.json b/src/assets/data/app.uri.json index 5f8781b..57b8c13 100644 --- a/src/assets/data/app.uri.json +++ b/src/assets/data/app.uri.json @@ -57,6 +57,11 @@ "URI": "/authentication/change-password", "UUID": "CHANGE_PASSWORD_URI" }, + { + "Id" : "ENTITY_FIRST_LOGIN_URI", + "URI": "/authentication/first-login", + "UUID": "FIRST_LOGIN_URI" + }, { "Id" : "ENTITY_USER_SAVE_PERMISSION", "URI": "/user/updatePermissions",