Skip to content

Commit 1d9d441

Browse files
authored
Merge pull request #1490 from microting/feat/eform-users-visibility-fallback-no-managers
feat: grant "eForm users" full planning view when no manager exists
2 parents 1c5114f + c530a81 commit 1d9d441

1 file changed

Lines changed: 23 additions & 0 deletions

File tree

eFormAPI/Plugins/TimePlanning.Pn/TimePlanning.Pn/Services/TimePlanningPlanningService/TimePlanningPlanningService.cs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,29 @@ await dbContext.AssignedSites
8989
var eFormAdminsGroup = userSecurityGroups
9090
.Any(x => x.SecurityGroup.Name == "eForm admins");
9191
isAdmin = eFormAdminsGroup;
92+
if (!isAdmin)
93+
{
94+
var isEformUsersGroup = userSecurityGroups
95+
.Any(x => x.SecurityGroup.Name == "eForm users");
96+
var isKunTidGroup = userSecurityGroups
97+
.Any(x => x.SecurityGroup.Name == "Kun tid");
98+
if (isEformUsersGroup && !isKunTidGroup)
99+
{
100+
// Fallback: when no user in the system is configured as a manager,
101+
// grant "eForm users" members the admin-for-visibility view on this
102+
// endpoint so the planning dashboard isn't empty in that degenerate
103+
// state. Users also in "Kun tid" (time-registration device users with
104+
// WebAccess) are explicitly excluded and stay restricted to own site.
105+
var anyManagerExists = await dbContext.AssignedSites
106+
.Where(x => x.WorkflowState != Constants.WorkflowStates.Removed)
107+
.AnyAsync(x => x.IsManager)
108+
.ConfigureAwait(false);
109+
if (!anyManagerExists)
110+
{
111+
isAdmin = true;
112+
}
113+
}
114+
}
92115
}
93116

94117
if (!isAdmin)

0 commit comments

Comments
 (0)