diff --git a/HRM.DA/Service/Users/RoleService.cs b/HRM.DA/Service/Users/RoleService.cs index 600aed5..9b8adb3 100644 --- a/HRM.DA/Service/Users/RoleService.cs +++ b/HRM.DA/Service/Users/RoleService.cs @@ -383,7 +383,8 @@ namespace HRM.DA } // Whoever made this change: the editor, or the creator for a new role. On approval // the controller keeps the maker in ModifiedBy, so this is still the maker. - int makerID = (oRole.ModifiedBy ?? 0) > 0 ? oRole.ModifiedBy.Value : oRole.CreatedBy; + // Super User IDs are negative, so "edited" means ModifiedBy is set (not 0), not "> 0". + int makerID = (oRole.ModifiedBy ?? 0) != 0 ? oRole.ModifiedBy.Value : oRole.CreatedBy; foreach (Role.RolePermission rolePermission in oRole.RolePermissions) { rolePermission.RoleID = oRole.ID; diff --git a/HRM.UI/ClientApp/src/app/authentication/role/role-permission-entry/role-permission-entry.component.ts b/HRM.UI/ClientApp/src/app/authentication/role/role-permission-entry/role-permission-entry.component.ts index e2c5793..c52c8eb 100644 --- a/HRM.UI/ClientApp/src/app/authentication/role/role-permission-entry/role-permission-entry.component.ts +++ b/HRM.UI/ClientApp/src/app/authentication/role/role-permission-entry/role-permission-entry.component.ts @@ -208,7 +208,8 @@ export class RolePermissionEntryComponent implements OnInit { this.allowSave = false; } else if (this.viewMode == 3) { - if (this._oldrole.modifiedBy == undefined) { + // Same maker rule as the list and the server: 0 / empty = never edited (IDs may be negative). + if (this._oldrole.modifiedBy == undefined || this._oldrole.modifiedBy == 0) { if (this._oldrole.createdBy == this.currentUser.userID) this.allowSave = false; else this.allowSave = true; diff --git a/HRM.UI/ClientApp/src/app/authentication/role/role-permission-list/role-permission-list.component.ts b/HRM.UI/ClientApp/src/app/authentication/role/role-permission-list/role-permission-list.component.ts index 673183d..401d0e8 100644 --- a/HRM.UI/ClientApp/src/app/authentication/role/role-permission-list/role-permission-list.component.ts +++ b/HRM.UI/ClientApp/src/app/authentication/role/role-permission-list/role-permission-list.component.ts @@ -92,7 +92,8 @@ export class RolePermissionListComponent implements OnInit { if (this.currentUserID == undefined || role == undefined) { return false; } - const makerID = (role.modifiedBy ?? 0) > 0 ? role.modifiedBy : role.createdBy; + // Super User IDs are negative: an edit is "modifiedBy set (not 0)", not "> 0". + const makerID = (role.modifiedBy ?? 0) !== 0 ? role.modifiedBy : role.createdBy; return makerID == this.currentUserID; } diff --git a/HRM.UI/Controllers/Auth/AuthController.cs b/HRM.UI/Controllers/Auth/AuthController.cs index 16902aa..3463c83 100644 --- a/HRM.UI/Controllers/Auth/AuthController.cs +++ b/HRM.UI/Controllers/Auth/AuthController.cs @@ -1341,7 +1341,8 @@ namespace HRM.UI.Controllers { return BadRequest("This role has no pending change to approve."); } - int makerID = (existingRole.ModifiedBy ?? 0) > 0 ? existingRole.ModifiedBy.Value : existingRole.CreatedBy; + // Super User IDs are negative: an edit is "ModifiedBy set (not 0)", not "> 0". + int makerID = (existingRole.ModifiedBy ?? 0) != 0 ? existingRole.ModifiedBy.Value : existingRole.CreatedBy; if (makerID == currentUser.UserID) { return BadRequest("You cannot approve a change you made yourself. Another user must approve it."); @@ -1593,7 +1594,8 @@ namespace HRM.UI.Controllers if ((currentUser.EmployeeID ?? 0) <= 0) return null; int superUserID = this._userService.GetUserId((int)currentUser.EmployeeID, EnumUserType.SuperUser); - return superUserID > 0 ? superUserID : (int?)null; + // GetUserId returns 0 when there is none; Super User IDs can be negative, so not "> 0". + return superUserID != 0 ? superUserID : (int?)null; } catch (Exception) { diff --git a/HRM.UI/appsettings.json b/HRM.UI/appsettings.json index fadd8ef..b164580 100644 --- a/HRM.UI/appsettings.json +++ b/HRM.UI/appsettings.json @@ -52,8 +52,8 @@ //"Default": "provider=sql;sqlSyntax=SQL;server=103.197.204.164,1718;Database=MasterProjectDB;User Id=DBuser;Password=ceLEa&e2025;TrustServerCertificate=True;", //"SqlCommandConnection": "Data Source=103.197.204.164,1718;Initial Catalog=autocrop;Persist Security Info=True; User ID=DBuser;Password=ceLEa&e2025;TrustServerCertificate=True;", // Development - "Default": "provider=sql;sqlSyntax=SQL;server=103.197.204.164,1718;Database=MasterProjectDBBRAC;User Id= DBuser;Password=ceLEa&e2025;TrustServerCertificate=True;", - "SqlCommandConnection": "Data Source=103.197.204.164,1718;Initial Catalog=MasterProjectDBBRAC;Persist Security Info=True; User ID=DBuser;Password=ceLEa&e2025;TrustServerCertificate=True;" // Development + "Default": "provider=sql;sqlSyntax=SQL;server=103.197.204.164,1718;Database=MasterProjectDBUATBRAC;User Id= DBuser;Password=ceLEa&e2025;TrustServerCertificate=True;", + "SqlCommandConnection": "Data Source=103.197.204.164,1718;Initial Catalog=MasterProjectDBUATBRAC;Persist Security Info=True; User ID=DBuser;Password=ceLEa&e2025;TrustServerCertificate=True;" // Development }, "Calendar": {