Browse Source

left pad role names :(

pull/102/head
Ethan Buchman 10 years ago
committed by Jae Kwon
parent
commit
b233f89dbf
1 changed files with 3 additions and 0 deletions
  1. +3
    -0
      permission/types/permissions.go

+ 3
- 0
permission/types/permissions.go View File

@ -108,6 +108,7 @@ func NewAccountPermissions() *AccountPermissions {
// Returns true if the role is found
func (aP *AccountPermissions) HasRole(role string) bool {
role = string(LeftPadBytes([]byte(role), 32))
for _, r := range aP.Roles {
if r == role {
return true
@ -118,6 +119,7 @@ func (aP *AccountPermissions) HasRole(role string) bool {
// Returns true if the role is added, and false if it already exists
func (aP *AccountPermissions) AddRole(role string) bool {
role = string(LeftPadBytes([]byte(role), 32))
for _, r := range aP.Roles {
if r == role {
return false
@ -129,6 +131,7 @@ func (aP *AccountPermissions) AddRole(role string) bool {
// Returns true if the role is removed, and false if it is not found
func (aP *AccountPermissions) RmRole(role string) bool {
role = string(LeftPadBytes([]byte(role), 32))
for i, r := range aP.Roles {
if r == role {
post := []string{}


Loading…
Cancel
Save