diff options
author | crupest <crupest@outlook.com> | 2020-11-13 16:20:45 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-11-13 16:20:45 +0800 |
commit | 299067a798077363d0df281fc3bfb4160df06e1f (patch) | |
tree | 9750c3e57d803efaa65a13c9c47886746d77d721 /BackEnd/Timeline/Services/UserRoleConvert.cs | |
parent | 0c789f235f38aa238048b31b9715810d397d3420 (diff) | |
parent | 79673878b5427bbedbc4ff4323dce3958d307b49 (diff) | |
download | timeline-299067a798077363d0df281fc3bfb4160df06e1f.tar.gz timeline-299067a798077363d0df281fc3bfb4160df06e1f.tar.bz2 timeline-299067a798077363d0df281fc3bfb4160df06e1f.zip |
Merge pull request #183 from crupest/auth
Refactor auth module to enable more flexiable permission control.
Diffstat (limited to 'BackEnd/Timeline/Services/UserRoleConvert.cs')
-rw-r--r-- | BackEnd/Timeline/Services/UserRoleConvert.cs | 43 |
1 files changed, 0 insertions, 43 deletions
diff --git a/BackEnd/Timeline/Services/UserRoleConvert.cs b/BackEnd/Timeline/Services/UserRoleConvert.cs deleted file mode 100644 index f27ee1bb..00000000 --- a/BackEnd/Timeline/Services/UserRoleConvert.cs +++ /dev/null @@ -1,43 +0,0 @@ -using System;
-using System.Collections.Generic;
-using System.Linq;
-using Timeline.Entities;
-
-namespace Timeline.Services
-{
- public static class UserRoleConvert
- {
- public const string UserRole = UserRoles.User;
- public const string AdminRole = UserRoles.Admin;
-
- public static string[] ToArray(bool administrator)
- {
- return administrator ? new string[] { UserRole, AdminRole } : new string[] { UserRole };
- }
-
- public static string[] ToArray(string s)
- {
- return s.Split(',').ToArray();
- }
-
- public static bool ToBool(IReadOnlyCollection<string> roles)
- {
- return roles.Contains(AdminRole);
- }
-
- public static string ToString(IReadOnlyCollection<string> roles)
- {
- return string.Join(',', roles);
- }
-
- public static string ToString(bool administrator)
- {
- return administrator ? UserRole + "," + AdminRole : UserRole;
- }
-
- public static bool ToBool(string s)
- {
- return s.Contains("admin", StringComparison.InvariantCulture);
- }
- }
-}
|