diff options
Diffstat (limited to 'code/api/Enums/UserRole.cs')
| -rw-r--r-- | code/api/Enums/UserRole.cs | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/code/api/Enums/UserRole.cs b/code/api/Enums/UserRole.cs new file mode 100644 index 0000000..86924b4 --- /dev/null +++ b/code/api/Enums/UserRole.cs @@ -0,0 +1,22 @@ +namespace Quality.Storage.Api.Enums; + +public enum UserRole +{ + LEAST_PRIVILEGED = 0, + ADMIN = 1, +} + +public static class UserRoleHelper +{ + public static UserRole FromString(string role) => role switch { + "least_privileged" => UserRole.LEAST_PRIVILEGED, + "admin" => UserRole.ADMIN, + _ => throw new ArgumentOutOfRangeException(nameof(role), role, null) + }; + + public static string ToString(UserRole role) => role switch { + UserRole.LEAST_PRIVILEGED => "least_privileged", + UserRole.ADMIN => "admin", + _ => throw new ArgumentOutOfRangeException(nameof(role), role, null) + }; +} |
