1+ /// Helper class to generate role strings for `Permission`.
12public class Role {
3+
4+ /// Grants access to anyone.
5+ ///
6+ /// This includes authenticated and unauthenticated users.
27 public static func any( ) -> String {
38 return " any "
49 }
510
11+ /// Grants access to a specific user by user ID.
12+ ///
13+ /// You can optionally pass verified or unverified for
14+ /// `status` to target specific types of users.
15+ ///
16+ /// @param String id
17+ /// @param String status
18+ /// @return String
619 public static func user( _ id: String , _ status: String = " " ) -> String {
720 if ( status. isEmpty) {
821 return " user: \( id) "
922 }
1023 return " user: \( id) / \( status) "
1124 }
1225
26+ /// Grants access to any authenticated or anonymous user.
27+ ///
28+ /// You can optionally pass verified or unverified for
29+ /// `status` to target specific types of users.
30+ ///
31+ /// @param String status
32+ /// @return String
1333 public static func users( _ status: String = " " ) -> String {
1434 if ( status. isEmpty) {
1535 return " users "
1636 }
1737 return " users/ \( status) "
1838 }
1939
40+ /// Grants access to any guest user without a session.
41+ ///
42+ /// Authenticated users don't have access to this role.
43+ ///
44+ /// @return String
2045 public static func guests( ) -> String {
2146 return " guests "
2247 }
2348
49+ /// Grants access to a team by team ID.
50+ ///
51+ /// You can optionally pass a role for `role` to target
52+ /// team members with the specified role.
53+ ///
54+ /// @param String id
55+ /// @param String role
56+ /// @return String
2457 public static func team( _ id: String , _ role: String = " " ) -> String {
2558 if ( role. isEmpty) {
2659 return " team: \( id) "
2760 }
2861 return " team: \( id) / \( role) "
2962 }
3063
64+ /// Grants access to a specific member of a team.
65+ ///
66+ /// When the member is removed from the team, they will
67+ /// no longer have access.
68+ ///
69+ /// @param String id
70+ /// @return String
3171 public static func member( _ id: String ) -> String {
3272 return " member: \( id) "
3373 }
74+
75+ /// Grants access to a user with the specified label.
76+ ///
77+ /// @param String name
78+ /// @return String
79+ public static func label( _ name: String ) -> String {
80+ return " label: \( name) "
81+ }
3482}
0 commit comments