Role and Permission approval issue

This commit is contained in:
Mohaimen Hasan 2026-11-25 10:26:32 +06:00
parent 9ccf2a514d
commit f0dd787c47
5 changed files with 12 additions and 7 deletions

View File

@ -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;

View File

@ -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;

View File

@ -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;
}

View File

@ -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)
{

View File

@ -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": {