ripple-api/app/v1/privileges.go

42 lines
1.6 KiB
Go
Raw Normal View History

2016-04-03 17:59:27 +00:00
package v1
import (
"github.com/osuripple/api/common"
)
type privilegesData struct {
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-03 17:59:27 +00:00
}
// PrivilegesGET returns an explaination for the privileges, telling the client what they can do with this token.
func PrivilegesGET(md common.MethodData) (r common.Response) {
// This code sucks.
r.Code = 200
r.Data = privilegesData{
2016-04-09 21:50:52 +00:00
Read: md.User.Privileges.HasPrivilegeRead(),
ReadConfidential: md.User.Privileges.HasPrivilegeReadConfidential(),
Write: md.User.Privileges.HasPrivilegeWrite(),
ManageBadges: md.User.Privileges.HasPrivilegeManageBadges(),
BetaKeys: md.User.Privileges.HasPrivilegeBetaKeys(),
ManageSettings: md.User.Privileges.HasPrivilegeManageSettings(),
ViewUserAdvanced: md.User.Privileges.HasPrivilegeViewUserAdvanced(),
ManageUser: md.User.Privileges.HasPrivilegeManageUser(),
ManageRoles: md.User.Privileges.HasPrivilegeManageRoles(),
ManageAPIKeys: md.User.Privileges.HasPrivilegeManageAPIKeys(),
Blog: md.User.Privileges.HasPrivilegeBlog(),
APIMeta: md.User.Privileges.HasPrivilegeAPIMeta(),
2016-04-03 17:59:27 +00:00
}
return
}