2016-07-03 19:55:03 +00:00
|
|
|
package common
|
|
|
|
|
2016-08-27 10:04:12 +00:00
|
|
|
import "strings"
|
|
|
|
|
2016-07-03 22:06:23 +00:00
|
|
|
// user/admin privileges
|
2016-07-03 19:55:03 +00:00
|
|
|
const (
|
2016-08-27 10:04:12 +00:00
|
|
|
UserPrivilegePublic UserPrivileges = 1 << iota
|
2016-07-03 19:55:03 +00:00
|
|
|
UserPrivilegeNormal
|
|
|
|
UserPrivilegeDonor
|
|
|
|
AdminPrivilegeAccessRAP
|
|
|
|
AdminPrivilegeManageUsers
|
|
|
|
AdminPrivilegeBanUsers
|
|
|
|
AdminPrivilegeSilenceUsers
|
|
|
|
AdminPrivilegeWipeUsers
|
|
|
|
AdminPrivilegeManageBeatmap
|
|
|
|
AdminPrivilegeManageServer
|
|
|
|
AdminPrivilegeManageSetting
|
|
|
|
AdminPrivilegeManageBetaKey
|
|
|
|
AdminPrivilegeManageReport
|
|
|
|
AdminPrivilegeManageDocs
|
|
|
|
AdminPrivilegeManageBadges
|
|
|
|
AdminPrivilegeViewRAPLogs
|
|
|
|
AdminPrivilegeManagePrivilege
|
|
|
|
AdminPrivilegeSendAlerts
|
|
|
|
AdminPrivilegeChatMod
|
|
|
|
AdminPrivilegeKickUsers
|
2016-08-27 10:04:12 +00:00
|
|
|
UserPrivilegePendingVerification
|
2016-10-06 14:57:01 +00:00
|
|
|
UserPrivilegeTournamentStaff
|
2016-07-03 19:55:03 +00:00
|
|
|
)
|
2016-08-27 10:04:12 +00:00
|
|
|
|
|
|
|
// UserPrivileges represents a bitwise enum of the privileges of an user.
|
|
|
|
type UserPrivileges uint64
|
|
|
|
|
|
|
|
var userPrivilegeString = [...]string{
|
|
|
|
"UserPublic",
|
|
|
|
"UserNormal",
|
|
|
|
"UserDonor",
|
|
|
|
"AdminAccessRAP",
|
|
|
|
"AdminManageUsers",
|
|
|
|
"AdminBanUsers",
|
|
|
|
"AdminSilenceUsers",
|
|
|
|
"AdminWipeUsers",
|
|
|
|
"AdminManageBeatmap",
|
|
|
|
"AdminManageServer",
|
|
|
|
"AdminManageSetting",
|
|
|
|
"AdminManageBetaKey",
|
|
|
|
"AdminManageReport",
|
|
|
|
"AdminManageDocs",
|
|
|
|
"AdminManageBadges",
|
|
|
|
"AdminViewRAPLogs",
|
|
|
|
"AdminManagePrivilege",
|
|
|
|
"AdminSendAlerts",
|
|
|
|
"AdminChatMod",
|
|
|
|
"AdminKickUsers",
|
|
|
|
"UserPendingVerification",
|
2016-10-06 14:57:01 +00:00
|
|
|
"UserTournamentStaff",
|
2016-08-27 10:04:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (p UserPrivileges) String() string {
|
|
|
|
var pvs []string
|
|
|
|
for i, v := range userPrivilegeString {
|
|
|
|
if uint64(p)&uint64(1<<uint(i)) != 0 {
|
|
|
|
pvs = append(pvs, v)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return strings.Join(pvs, ", ")
|
|
|
|
}
|