Documentation
¶
Index ¶
- Constants
- Variables
- func GetStaffFromRequest(request *http.Request) (*gcsql.Staff, error)
- func GetStaffRank(request *http.Request) int
- func InitManagePages()
- func PreloadModule(l *lua.LState) int
- func RegisterManagePage(id string, title string, permissions int, jsonOutput int, ...)
- type Action
- type CallbackFunction
- type ErrStaffAction
Constants ¶
View Source
const ( // NoPerms allows anyone to access this Action NoPerms = iota // JanitorPerms allows anyone with at least a janitor-level account to access this Action JanitorPerms // ModPerms allows anyone with at least a moderator-level account to access this Action ModPerms // AdminPerms allows only the site administrator to view this Action AdminPerms )
View Source
const ( // NoJSON actions will return an error if JSON is requested by the user NoJSON = iota // OptionalJSON actions have an optional JSON output if requested OptionalJSON // AlwaysJSON actions always return JSON whether or not it is requested AlwaysJSON )
Variables ¶
View Source
var ( ErrBadCredentials = errors.New("invalid username or password") ErrUnableToCreateSession = errors.New("unable to create login session") ErrInvalidSession = errors.New("invalid staff session") )
View Source
var (
ErrInsufficientPermission = server.NewServerError("insufficient account permission", http.StatusForbidden)
)
View Source
var (
ErrPasswordsDoNotMatch = errors.New("passwords do not match")
)
Functions ¶
func GetStaffFromRequest ¶
GetStaffFromRequest returns the staff making the request. If the request does not have a staff cookie, it will return a staff object with rank 0. Deprecated: use gcsql.GetStaffFromRequest
func GetStaffRank ¶
GetStaffRank returns the rank number of the staff referenced in the request
func PreloadModule ¶
func RegisterManagePage ¶
func RegisterManagePage(id string, title string, permissions int, jsonOutput int, callback CallbackFunction)
Types ¶
type Action ¶
type Action struct { // ID is the string used when the user requests /manage/<ID> ID string `json:"id"` // Title is used for the text shown in the staff menu and the window title Title string `json:"title"` // Permissions represent who can access the page. 0 for anyone, // 1 requires the user to have a janitor, mod, or admin account. 2 requires mod or admin, // and 3 is only accessible by admins Permissions int `json:"perms"` // Hidden is used to hide the action from the staff menu Hidden bool `json:"-"` // JSONoutput sets what the action can output. If it is 0, it will throw an error if // JSON is requested. If it is 1, it can output JSON if requested, and if 2, it always // outputs JSON whether it is requested or not JSONoutput int `json:"jsonOutput"` // if it can sometimes return JSON, this should still be false // Callback executes the staff page. if wantsJSON is true, it should return an object // to be marshalled into JSON. Otherwise, a string assumed to be valid HTML is returned. // // IMPORTANT: the writer parameter should only be written to if absolutely necessary (for example, // if a redirect wouldn't work in handler.go) and even then, it should be done sparingly Callback CallbackFunction `json:"-"` }
Action represents the functions accessed by staff members at /manage/<functionname>.
type CallbackFunction ¶
type ErrStaffAction ¶
type ErrStaffAction struct { // ErrorField can be used in the frontend for giving more specific info about the error ErrorField string `json:"error"` Action string `json:"action"` Message string `json:"message"` }
func (*ErrStaffAction) Error ¶
func (esa *ErrStaffAction) Error() string
Click to show internal directories.
Click to hide internal directories.