pageReadOnly returns true when the authenticated user is a mod who lacks the write permission for the current admin page. Admins always have full access.
(r *http.Request)
| 43 | // pageReadOnly returns true when the authenticated user is a mod who lacks the |
| 44 | // write permission for the current admin page. Admins always have full access. |
| 45 | func pageReadOnly(r *http.Request) bool { |
| 46 | u := GetAuthedUser(r) |
| 47 | if u == nil || u.Role == users.RoleAdmin { |
| 48 | return false |
| 49 | } |
| 50 | writeKey, ok := pageWritePermissions[strings.TrimRight(r.URL.Path, "/")] |
| 51 | if !ok { |
| 52 | return false |
| 53 | } |
| 54 | return !u.HasPermission(writeKey) |
| 55 | } |
| 56 | |
| 57 | // serveAdminTemplate is a helper that parses and executes a named admin HTML |
| 58 | // template, merging any extra data into the standard template data map. |
no test coverage detected