diff --git a/CLAUDE.md b/CLAUDE.md index 3bfafc2..5a88b94 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -294,8 +294,8 @@ the screens report problems the same way. Neither has a `` node yet either workbook is per salary month (row 1 carries the month, checked against the month posted as the `salaryMonth` form field). **7** layers, not 8, and layers 4–7 all run once layer 3 passes, so one upload lists every problem of every row. A blank amount is saved as `NULL` — which needs - `HistorySalaryMonthlyAmountNull_DB_Changes.sql` run first. That script was deleted from the root in - `91369150c` (not archived): recover it with + `HistorySalaryMonthlyAmountNull_DB_Changes.sql` run first. That script is not in this repo — it was + deleted (not archived) in `cel.hrm` commit `91369150c`; recover it from there with `git show 91369150c^:HistorySalaryMonthlyAmountNull_DB_Changes.sql`. The service opens no transaction itself; the save is `HistorySalaryMonthlyService`'s one all-or-nothing transaction. - **Employee Profile Picture Bulk Upload** (second tab of the Employee Bulk Upload screen; @@ -324,8 +324,8 @@ A Google-Calendar-like module (`/calendar/my-calendar`, `/calendar/my-tasks`) on header like `GeneralMail`), sent by `CalendarJobs.SendScheduleEmail` through `IEmailDispatchService` — so it shows, and is retried, in Mail Manager › Mail Log History. Body/subject tags (``, ``, …) are listed and filled in one place, `HRM.DA/Service/Calendar/ScheduleEmailTags.cs`. - Schema: `ScheduleEmail_DB_Changes.sql` was deleted from the root once applied (commit `ac179c03e`) - and **not** archived in `db/Script/` — recover it with `git show 73f466cd0:ScheduleEmail_DB_Changes.sql`. + Schema: `ScheduleEmail_DB_Changes.sql` is **not** in this repo — it was deleted unarchived in `cel.hrm`; + recover it from a `cel.hrm` clone with `git show 73f466cd0:ScheduleEmail_DB_Changes.sql`. - The organizer is `CreatedBy` **and** an attendee row with `Role = Organizer`. Holidays, leave and birthdays are read-only layers, read live from the existing tables (nothing is copied). - Repeats are RFC 5545 RRULEs worked out with **Ical.Net** (`HRM.DA/Service/Calendar/CalendarRecurrence.cs`). @@ -463,18 +463,23 @@ When behavior differs between clients, look for or add a Logic key rather than b ## Branches: one product, many client deployments -`origin` (`103.197.204.162:3025/CelHRTeam/cel.hrm`) carries ~79 branches, and they are not short-lived -feature branches. The default/integration branch is **`devqc`**. The rest are long-lived **per-client** -branches (`BergerHR`, `SGSHR`, `IDLC_Payroll_Master`, `Square_PMS*`, `Wartsila`, `LiFungHR`, -`Metlife_fund`, `PetromaxHR`, `ProclozPayroll`, `TexEbo_Payroll`, `Duncan_Payroll`, `HNM`, `PCSHRUAT`, -…) and **per-developer** ones (`dev_`, `dev_Master`). +**This checkout is not that repo.** It is `HRM-10` (`origin` = `103.197.204.162:3025/CelHRTeam/HRM-10`), +a fresh import with a single branch `main` and a single squashed commit (`838b8d4` "first commit"). +None of the older history exists here: every commit hash quoted elsewhere in this file (`c8588ce67`, +`91369150c`, `ac179c03e`, `73f466cd0`, `bfd085e0e`) is from the original `CelHRTeam/cel.hrm` repo, and +`git show`/`git log` recovery commands only work in a clone of that repo, not here. + +That original repo carries ~79 branches, and they are not short-lived feature branches. Its +default/integration branch is **`devqc`**. The rest are long-lived **per-client** branches +(`BergerHR`, `SGSHR`, `IDLC_Payroll_Master`, `Square_PMS*`, `Wartsila`, `LiFungHR`, `Metlife_fund`, +`PetromaxHR`, `ProclozPayroll`, `TexEbo_Payroll`, `Duncan_Payroll`, `HNM`, `PCSHRUAT`, …) and +**per-developer** ones (`dev_`, `dev_Master`). Two consequences worth holding onto: -- Work moves between client branches by hand, as bulk "transferred from ``" commits — e.g. - `c8588ce67` "works transfered from square_pms". So a fix made here is *not* automatically in any - other client's branch, and a file can look freshly rewritten when it was only ported. Check - `git log --follow` before assuming a recent change was authored for this branch. +- Work moves between client branches by hand, as bulk "transferred from ``" commits. So a fix + made here is *not* automatically in any client's branch of `cel.hrm` (and vice versa), and a file + can look freshly rewritten when it was only ported. - This is *why* per-client behavior belongs in uploaded `*LogicConfiguration.xml` / `*-Menu.xml` data and in the `Calendar` appsettings section rather than in `if (client == …)` code: config travels with the database, code branching has to be re-merged across ~79 branches. @@ -540,22 +545,19 @@ Schema/proc changes are hand-authored `.sql` scripts named `_DB_Changes each database **manually**. They live in two places and the distinction is the whole point: - **Repo root** — the *pending* ones. `ls *_DB_Changes.sql` shows what has not been applied yet - (the list changes every few days — run it rather than trusting a written-down list). Write new - scripts here, in the same commit as the code that needs them. -- **[`db/Script/`](db/Script)** — the archive of shipped ones. Applied scripts used to be deleted - outright; commit `c8588ce67` (2026-10-13) instead *moved* the five applied ones here - (`Calendar`, `MenuIcon`, `AttendanceLeaveSummaryLM`, `TaxParameterEssDeadline`, - `PMS_SquareAlign_IDP`). Read them for precedent — they are the best worked examples of house style - — but don't re-run one against a database that already has it. + (at the initial import there were none). Write new scripts here, in the same commit as the code + that needs them. +- **[`db/Script/`](db/Script)** — the archive of shipped ones (`Calendar`, `MenuIcon`, + `AttendanceLeaveSummaryLM`, `TaxParameterEssDeadline`, `PMS_SquareAlign_IDP`, `EmpHistoricalData`). + Read them for precedent — they are the best worked examples of house style — but don't re-run one + against a database that already has it. -The convention is not enforced: `bfd085e0e` (Historical Data Upload) committed -`EmpHistoricalData_DB_Changes.sql` straight into `db/Script/`. So the root listing is not a complete -"pending" list — before deploying a branch to a database, also check `git log -- db/Script` for -scripts added since that database was last updated. It also breaks the other way: applied scripts -are still sometimes deleted instead of moved (`ScheduleEmail`, `UserEmailAddress`, -`HistorySalaryMonthlyAmountNull`, … in `ac179c03e` / `73f466cd0` / `91369150c`), so for those the only -copy is git history (`git show ^:`) — -`git log --diff-filter=D --name-only -- '*_DB_Changes.sql'` lists them. +The convention was not enforced in `cel.hrm`: `EmpHistoricalData` went straight into `db/Script/`, +and several applied scripts were deleted instead of archived — `ScheduleEmail`, `UserEmailAddress`, +`HistorySalaryMonthlyAmountNull` and others. **None of those deleted scripts exist in this repo**; +the only copies are in `cel.hrm` history (`git log --diff-filter=D --name-only -- '*_DB_Changes.sql'` +there). A fresh database built from this repo's scripts alone will be missing that schema, as well as +the never-scripted `MasterEmailLog` tables. Every script is guarded and re-runnable (`IF COL_LENGTH(...) IS NULL`, `IF OBJECT_ID(...) IS NULL`, `sp_rename` only when the old name is still there), documents its own run order, and states whether @@ -705,8 +707,3 @@ A typical feature commit touches, in order: 6. `ClientApp/src/app/_models//.ts` and `_services//.service.ts` 7. the feature component(s) under `ClientApp/src/app//` 8. a root `_DB_Changes.sql` if the schema changes - -## Editor rules - -`.github/copilot-instructions.md` requires: for anything Azure-related, always use the Azure tools and -invoke `azmcp_bestpractices_get` first; if that tool isn't available, ask the user to enable it. diff --git a/HRM.UI/ClientApp/src/app/_guards/idle.service.ts b/HRM.UI/ClientApp/src/app/_guards/idle.service.ts new file mode 100644 index 0000000..1e84b38 --- /dev/null +++ b/HRM.UI/ClientApp/src/app/_guards/idle.service.ts @@ -0,0 +1,47 @@ +import { Injectable, NgZone } from '@angular/core'; +import { fromEvent, merge, timer } from 'rxjs'; +import { switchMap } from 'rxjs/operators'; + +@Injectable({ + providedIn: 'root' +}) +export class IdleService { + private isTrackingEnabled = true; + private timeout = 5 * 60 * 1000; // 5 min + + constructor(private ngZone: NgZone) {} + + startWatching(onTimeout: () => void) { + + this.ngZone.runOutsideAngular(() => { + + const events$ = merge( + fromEvent(document, 'mousemove'), + fromEvent(document, 'click'), + fromEvent(document, 'keydown'), + fromEvent(document, 'scroll') + ); + + events$ + .pipe( + switchMap(() => timer(this.timeout)) + ) + .subscribe(() => { + if (this.isTrackingEnabled == false) return; //disable + + this.ngZone.run(() => { + onTimeout(); + }); + }); + + }); + } + + stopTracking() { + this.isTrackingEnabled = false; + } + + startTracking() { + this.isTrackingEnabled = true; + } +} \ No newline at end of file diff --git a/HRM.UI/ClientApp/src/app/_services/auth/auth.service.ts b/HRM.UI/ClientApp/src/app/_services/auth/auth.service.ts index 0a37ed4..19ad453 100644 --- a/HRM.UI/ClientApp/src/app/_services/auth/auth.service.ts +++ b/HRM.UI/ClientApp/src/app/_services/auth/auth.service.ts @@ -18,6 +18,7 @@ import { Subject } from 'rxjs'; import { PendingJobDTO } from 'src/app/_models/Work-Flow/pendingJobDTO'; import { DataPermission } from 'src/app/_models/Basic/DataPermission'; import { BehaviorSubject } from 'rxjs'; +import { IdleService } from 'src/app/_guards/idle.service'; @Injectable({ providedIn: 'root' }) export class AuthService { @@ -39,7 +40,6 @@ export class AuthService { getIsFromSuperUser(): boolean { return this.isFromSuperUserSubject.value; } - private isFromUserSubject = new BehaviorSubject(false); isFromUser$ = this.isFromUserSubject.asObservable(); setIsFromUser(value: boolean) { @@ -48,22 +48,29 @@ export class AuthService { // bookmarks: Bookmark[]; constructor(private http: HttpClient, public apiService: ApiService , - public notificationService: HRMNotificationService, private router: Router) { + public notificationService: HRMNotificationService, private router: Router, private idleService: IdleService) { this.subject = new Subject(); this.subject2 = new Subject(); // this.loadBookmark(); // console.log(this.bookmarks); } - login(model: any) { return this.http.post(this.apiService.base_url + '/Authentication/login', model).pipe( map((response: any) => { const user = response; if (user) { - // debugger; - localStorage.setItem('token', user); - ApiService.AuthenticationToken = user; - // this.decodedToken = this.jwtHelper.decodeToken(ApiService.AuthenticationToken); + if(user.mfaRequired){ + ApiService.isMFA = true; + ApiService.AuthenticationMFASessionID = user. mfaSessionId; + } + else{ + ApiService.isMFA = false; + ApiService.AuthenticationMFASessionID = ''; + localStorage.setItem('token', user); + ApiService.AuthenticationToken = user; + //idle logout + this.idleService.stopTracking(); + } } }) ); @@ -76,43 +83,34 @@ export class AuthService { localStorage.removeItem('pendingjobs'); localStorage.setItem('pendingjobs', JSON.stringify(pendingJobDTOs)); } - userPayrolltypeSwitch(param: any): any { return this.apiService.httpPost('/Authentication/userPayrolltypeSwitch', param); } SwtichUserMode(param: any): any { return this.apiService.httpPost('/Authentication/switchuser', param); } - GetLogInUserType(): any { return this.apiService.httpGet('/Authentication/GetLogInUserType'); } - GetCurrentUser(): any { return this.apiService.httpGet('/Authentication/GetCurrentUser'); } getUserByEmail(email: string) { return this.apiService.httpGet('/Authentication/getUserByEmail/' + email); } - GetUsers(usertype: EnumUserType, loginidid?: string, name?: string): any { //const params = { // LogInID: loginid == undefined ? '' : loginid, // Name: name == undefined ? '' : name, // userType: usertype //}; - const nname = this.apiService.getApiDefaultData(name); const sloginid = this.apiService.getApiDefaultData(loginidid); - return this.apiService.httpGet('/Authentication/GetUsers/' + usertype + '/' + loginidid + '/' + name); } - GetAllEmpNotYetUser() { return this.apiService.httpGet('/Authentication/GetAllEmpNotYetUser'); - } - logout() { localStorage.removeItem('forgotpass'); localStorage.removeItem('bookmark'); @@ -124,16 +122,12 @@ export class AuthService { this.logoutSource.next(); this.router.navigate(['/login']); } - - SaveUser(oUser: User): any { return this.apiService.httpPost('/Authentication/SaveUser', oUser); } - ApproveUser(oUser: User): any { return this.apiService.httpPost('/Authentication/ApproveUser', oUser); } - DoActiveAndIntacive(oUser: User): any { return this.apiService.httpPost('/Authentication/DoActiveAndIntacive', oUser); } @@ -143,64 +137,47 @@ export class AuthService { getBookmarks() { return this.apiService.httpGet('/Authentication/getBookmarks'); } - SaveBookmark(oBookmark: Bookmark): any { return this.apiService.httpPost('/Authentication/SaveBookmark', oBookmark); } - deleteBookmark(param: any) { return this.apiService.httpPost('/Authentication/deleteBookmark', param); } - deleteBookmarkByMenuKey(param: any) { return this.apiService.httpPost('/Authentication/deleteBookmarkByMenuKey', param); } - getPendingJob(employeeId: number) { return this.apiService.httpGet('/Workflow/getPendingJob' + '/' + employeeId); } markNotificationsAsRead(ids: number[]) { return this.apiService.httpPost('/Workflow/MarkNotificationsAsRead', ids); } - loggedIn() { const token = localStorage.getItem('token'); ApiService.AuthenticationToken = token; return !this.jwtHelper.isTokenExpired(token); } - register(user: User) { return this.http.post(this.baseUrl + 'register', user); } - loadMenu() { return this.http.get(this.baseUrl + 'loadMenu'); } - getAllRoles() { return this.apiService.httpGet('/Authentication/getAllRoles'); } - - - getRole(roleID: number) { return this.apiService.httpGet('/Authentication/getRole/' + roleID); } - - getMenuesFromConfig() { return this.apiService.httpGet('/Authentication/getMenuesFromConfig'); } - saveRole(params: Role) { return this.apiService.httpPost('/Authentication/saveRole', params); } - GetRolePermissionbyUserID() { return this.apiService.httpGet('/Authentication/GetRolePermissionbyUserID'); } - - getUserRoles(roletype: EnumRoleType, userID?: number, roleid?: number) { const nuserid = this.apiService.getApiDefaultIntData(userID); @@ -209,66 +186,51 @@ export class AuthService { return this.apiService.httpGet('/Authentication/getUserRoles/' + roletype + '/' + nuserid + '/' + nroletype); } - - GetEmpUserRole(searchemps: SearchEmployee[]) { return this.apiService.httpPost('/Authentication/GetEmpUserRole', searchemps); } - saveUserRole(params: any) { return this.apiService.httpPost('/Authentication/saveUserRole', params); } - - GetAllPayrollTypes() { return this.apiService.httpGet('/Authentication/GetAllPayrollTypes'); } - GetPayrollTypesByLoginID(loginID: string) { return this.apiService.httpGet('/Authentication/GetPayrollTypesByLoginID/' + loginID); } GetBenifitsProcessStatus() { return this.apiService.httpGet('/Authentication/GetBenifitsProcessStatus' ); } - getSwitchUserId(usertype: EnumUserType) { return this.apiService.httpGet('/Authentication/getSwitchUserId/'+ usertype); } - GetPayrollTypeByLoginID() { return this.apiService.httpGet('/Authentication/GetPayrollTypeByLoginID'); } getAdminPayrollTypes() { return this.apiService.httpGet('/Authentication/getAdminPayrollTypes'); } - GetUserAccessType(userid: number) { return this.apiService.httpGet('/Authentication/GetUserAccessType/' + userid); } - SaveUserAccessType(acesssTypes: UserAccessType[]) { return this.apiService.httpPost('/Authentication/SaveUserAccessType', acesssTypes); } - changePassword(userData: any) { return this.apiService.httpPost('/Authentication/changePassword', userData); } - changePasswordbyAdmin(userData: any) { return this.apiService.httpPost('/Authentication/changePasswordbyAdmin', userData); } - forgotPassword(data: any) { return this.apiService.httpPost('/Authentication/forgotPassword', data); } - getVersionNumber() { return this.apiService.httpGet('/Authentication/getVersionNumber'); } - GetUserByLoingID(loginid: string, systemType: EnumSystemType) { return this.apiService.httpGet('/Authentication/GetUserByLoingID/' + loginid + '/' + systemType); } @@ -279,19 +241,15 @@ export class AuthService { getUserByUserType(param: any): any { return this.apiService.httpPost('/Authentication/getUserByUserType', param); } - - addPermission(param: any) { return this.apiService.httpPost('/Authentication/addPermission', param); } - loadDataPermission(userid: number, payrolltypeid:number) { return this.apiService.httpGet('/Authentication/loadDataPermission/' + userid + "/" + payrolltypeid); } DeletedataPermission(item:any) { return this.apiService.httpPost ('/Authentication/deletePermission' ,item); } - getSSOStatus() { return this.apiService.httpGet('/Authentication/getSSOStatus'); } @@ -302,4 +260,26 @@ export class AuthService { const fmt = (d: Date) => d.getFullYear() + '-' + ('0' + (d.getMonth() + 1)).slice(-2) + '-' + ('0' + d.getDate()).slice(-2); return this.apiService.httpGet('/Authentication/SetExpectedSalaryandApprovalDate'+ '/' + fmt(expectedDate) + '/' + fmt(expectedApprovalDate)); } + VerifyMfa(model: any) { + return this.http.post(this.apiService.base_url + '/Authentication/verify-mfa', model).pipe( + map((response: any) => { + const user = response; + localStorage.setItem('token', user.userToken); + ApiService.AuthenticationToken = user.userToken; + }) + ); + } + ResendOTP(model: any): any { + return this.http.post(this.apiService.base_url + '/Authentication/resend-otp', model).pipe( + map((response: any) => { + const user = response; + if (user) { + if(user.mfaRequired){ + ApiService.isMFA = true; + ApiService.AuthenticationMFASessionID = user. mfaSessionId; + } + } + }) + ); + } } diff --git a/HRM.UI/ClientApp/src/app/app.api.service.ts b/HRM.UI/ClientApp/src/app/app.api.service.ts index edc30d3..5bf29d8 100644 --- a/HRM.UI/ClientApp/src/app/app.api.service.ts +++ b/HRM.UI/ClientApp/src/app/app.api.service.ts @@ -14,6 +14,8 @@ import { environment } from '../environments/environment'; export class ApiService { public isSSO = false; + public static isMFA : boolean = false; + public isADLogin = false; public versionDeployement = false; public versionNumber = "20261012-01"; public static BASE_URL = ''; @@ -24,6 +26,7 @@ export class ApiService { public static PAYROLLTYPEID: number = 0; public static USERTYPE: number = 0; public isSelService : boolean = true; + public static MFACode: string = undefined; public isSelServiceFullScreen : boolean = false; public isNewDaswhboard : boolean = true; public menuItems: any[] = []; @@ -36,6 +39,7 @@ export class ApiService { public static AuthenticationToken = ''; public static readonly DEFAULT_PHOTO = './assets/photos/profile-default.jpg'; public selectedMenuName: string = ''; + public static AuthenticationMFASessionID = ''; constructor(public httpClient: HttpClient, public datepipe: DatePipe) { if (!ApiService.AuthenticationToken) { diff --git a/HRM.UI/ClientApp/src/app/login.component.html b/HRM.UI/ClientApp/src/app/login.component.html index 48f483a..3b63dbd 100644 --- a/HRM.UI/ClientApp/src/app/login.component.html +++ b/HRM.UI/ClientApp/src/app/login.component.html @@ -15,8 +15,6 @@ @if (!apiService.isSSO) {