FromString converts string to UserPermissionRole.
(perm string)
| 118 | |
| 119 | // FromString converts string to UserPermissionRole. |
| 120 | func (r *UserPermissionRole) FromString(perm string) { |
| 121 | if perm == "Void" { |
| 122 | *r = Void |
| 123 | return |
| 124 | } else if perm == "Admin" { |
| 125 | *r = Admin |
| 126 | return |
| 127 | } |
| 128 | |
| 129 | *r = Void |
| 130 | |
| 131 | for _, p := range strings.Split(perm, ",") { |
| 132 | p = strings.TrimSpace(p) |
| 133 | switch p { |
| 134 | case "Read": |
| 135 | *r |= Read |
| 136 | case "Write": |
| 137 | *r |= Write |
| 138 | case "Super": |
| 139 | *r |= Super |
| 140 | } |
| 141 | } |
| 142 | } |
| 143 | |
| 144 | // UserPermissionFromRole construct a new user permission instance from primitive user permission role enum. |
| 145 | func UserPermissionFromRole(role UserPermissionRole) *UserPermission { |
no outgoing calls