Browse Source

Add Bancho privilege

master
Giuseppe Guerra 1 year ago
parent
commit
34f24b8de6
No known key found for this signature in database GPG Key ID: 9EA37497681B13F9
1 changed files with 4 additions and 0 deletions
  1. +4
    -0
      common/privileges.go

+ 4
- 0
common/privileges.go View File

@@ -17,6 +17,7 @@ const (
PrivilegeBlog // can do pretty much anything to the blog, and the documentation.
PrivilegeAPIMeta // can do /meta API calls. basically means they can restart the API server.
PrivilegeBeatmap // rank/unrank beatmaps. also BAT when implemented
PrivilegeBancho // can log in to bancho and use the chat through the delta ws api
)

// Privileges is a bitwise enum of the privileges of an user's API key.
@@ -36,6 +37,7 @@ var privilegeString = [...]string{
"Blog",
"APIMeta",
"Beatmap",
"Bancho",
}

func (p Privileges) String() string {
@@ -62,6 +64,7 @@ var privilegeMustBe = [...]UserPrivileges{
AdminPrivilegeChatMod, // temporary?
AdminPrivilegeManageServer,
AdminPrivilegeAccessRAP | AdminPrivilegeManageBeatmap,
UserPrivilegeNormal,
}

// CanOnly removes any privilege that the user has requested to have, but cannot have due to their rank.
@@ -81,6 +84,7 @@ func (p Privileges) CanOnly(userPrivs UserPrivileges) Privileges {
var privilegeMap = map[string]Privileges{
"read_confidential": PrivilegeReadConfidential,
"write": PrivilegeWrite,
"bancho": PrivilegeBancho,
}

// OAuthPrivileges returns the equivalent in Privileges of a space-separated


Loading…
Cancel
Save