MCPcopy Create free account
hub / github.com/GoMudEngine/GoMud / pageReadOnly

Function pageReadOnly

internal/web/admin_items.go:45–55  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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.
45func 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.

Callers 3

serveAdminTemplateFunction · 0.85
RegisterAdminPageMethod · 0.85
adminIndexFunction · 0.85

Calls 2

GetAuthedUserFunction · 0.85
HasPermissionMethod · 0.80

Tested by

no test coverage detected