Add team roles and content management updates
This commit is contained in:
@@ -3,9 +3,13 @@ namespace Backend.Security;
|
||||
public static class AdminRoles
|
||||
{
|
||||
public const string Viewer = "viewer";
|
||||
public const string Member = "member";
|
||||
public const string Reviewer = "reviewer";
|
||||
public const string OrganizationTeam = "organization_team";
|
||||
public const string ContentAdmin = "content_admin";
|
||||
public const string Admin = "admin";
|
||||
public const string Owner = "owner";
|
||||
public const string Creator = "creator";
|
||||
|
||||
public static string Normalize(string? role)
|
||||
{
|
||||
@@ -14,8 +18,19 @@ public static class AdminRoles
|
||||
return normalizedRole switch
|
||||
{
|
||||
Owner => Owner,
|
||||
Creator => Creator,
|
||||
Admin => Admin,
|
||||
ContentAdmin => ContentAdmin,
|
||||
"creator_role" => Creator,
|
||||
"creatorrolle" => Creator,
|
||||
"admins" => Admin,
|
||||
"mitglied" => Member,
|
||||
"member" => Member,
|
||||
"reviewer" => Reviewer,
|
||||
"organisation_team" => OrganizationTeam,
|
||||
"organisationteam" => OrganizationTeam,
|
||||
"organization_team" => OrganizationTeam,
|
||||
"organizationteam" => OrganizationTeam,
|
||||
_ => Viewer,
|
||||
};
|
||||
}
|
||||
@@ -23,18 +38,30 @@ public static class AdminRoles
|
||||
public static bool IsKnownRole(string? role)
|
||||
{
|
||||
var normalizedRole = (role ?? string.Empty).Trim().ToLowerInvariant().Replace('-', '_');
|
||||
return normalizedRole is Viewer or ContentAdmin or Admin or Owner;
|
||||
return Normalize(normalizedRole) is Viewer or Member or Reviewer or OrganizationTeam or ContentAdmin or Admin or Owner or Creator;
|
||||
}
|
||||
|
||||
public static bool CanAccessAdmin(string? role) =>
|
||||
Normalize(role) is ContentAdmin or Admin or Owner;
|
||||
Normalize(role) is Member or Reviewer or OrganizationTeam or ContentAdmin or Admin or Owner or Creator;
|
||||
|
||||
public static bool CanManageContent(string? role) =>
|
||||
Normalize(role) is ContentAdmin or Admin or Owner;
|
||||
Normalize(role) is ContentAdmin or Admin or Owner or Creator;
|
||||
|
||||
public static bool CanManageAdminWorkspace(string? role) =>
|
||||
Normalize(role) is Admin or Owner;
|
||||
Normalize(role) is Admin or Owner or Creator;
|
||||
|
||||
public static bool CanManageOperationalSettings(string? role) =>
|
||||
Normalize(role) is Owner;
|
||||
Normalize(role) is Owner or Creator;
|
||||
|
||||
public static bool CanManageTeam(string? role) =>
|
||||
Normalize(role) is Admin or Owner or Creator;
|
||||
|
||||
public static bool CanResetTeamPasswords(string? role) =>
|
||||
Normalize(role) is Owner or Creator;
|
||||
|
||||
public static bool CanDeleteTeamMembers(string? role) =>
|
||||
Normalize(role) is Owner or Creator;
|
||||
|
||||
public static bool IsPrivilegedFullControlRole(string? role) =>
|
||||
Normalize(role) is Owner or Creator;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user