ripple-api/app/v1/privileges.go

44 lines
1.6 KiB
Go
Raw Normal View History

2016-04-03 17:59:27 +00:00
package v1
import (
2016-04-19 14:07:27 +00:00
"git.zxq.co/ripple/rippleapi/common"
2016-04-03 17:59:27 +00:00
)
type privilegesData struct {
2016-04-16 16:05:24 +00:00
common.ResponseBase
2016-04-09 21:50:52 +00:00
Read bool `json:"read"`
ReadConfidential bool `json:"read_confidential"`
Write bool `json:"write"`
ManageBadges bool `json:"manage_badges"`
BetaKeys bool `json:"beta_keys"`
ManageSettings bool `json:"manage_settings"`
ViewUserAdvanced bool `json:"view_user_advanced"`
ManageUser bool `json:"manage_user"`
ManageRoles bool `json:"manage_roles"`
ManageAPIKeys bool `json:"manage_api_keys"`
Blog bool `json:"blog"`
APIMeta bool `json:"api_meta"`
2016-04-27 18:25:53 +00:00
Beatmap bool `json:"beatmap"`
2016-04-03 17:59:27 +00:00
}
// PrivilegesGET returns an explaination for the privileges, telling the client what they can do with this token.
2016-04-16 16:05:24 +00:00
func PrivilegesGET(md common.MethodData) common.CodeMessager {
r := privilegesData{}
2016-04-03 17:59:27 +00:00
r.Code = 200
2016-04-16 16:05:24 +00:00
// This code sucks.
r.Read = true
2016-04-16 16:05:24 +00:00
r.ReadConfidential = md.User.Privileges.HasPrivilegeReadConfidential()
r.Write = md.User.Privileges.HasPrivilegeWrite()
r.ManageBadges = md.User.Privileges.HasPrivilegeManageBadges()
r.BetaKeys = md.User.Privileges.HasPrivilegeBetaKeys()
r.ManageSettings = md.User.Privileges.HasPrivilegeManageSettings()
r.ViewUserAdvanced = md.User.Privileges.HasPrivilegeViewUserAdvanced()
r.ManageUser = md.User.Privileges.HasPrivilegeManageUser()
r.ManageRoles = md.User.Privileges.HasPrivilegeManageRoles()
r.ManageAPIKeys = md.User.Privileges.HasPrivilegeManageAPIKeys()
r.Blog = md.User.Privileges.HasPrivilegeBlog()
r.APIMeta = md.User.Privileges.HasPrivilegeAPIMeta()
2016-04-27 18:25:53 +00:00
r.Beatmap = md.User.Privileges.HasPrivilegeBeatmap()
2016-04-16 16:05:24 +00:00
return r
2016-04-03 17:59:27 +00:00
}