Skip to content
This repository has been archived by the owner on May 13, 2022. It is now read-only.

Commit

Permalink
Merge branch 'feature-tendermint_0.8.0' into feature-tendermint_0.8.0
Browse files Browse the repository at this point in the history
  • Loading branch information
benjaminbollen authored Feb 23, 2017
2 parents c0da1cb + 5df1939 commit 9efaad7
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions permission/types/permissions.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ package types

import (
"fmt"
"strings"

"github.com/eris-ltd/eris-db/word256"
)
Expand Down Expand Up @@ -237,35 +238,37 @@ func PermFlagToString(pf PermFlag) (perm string) {
return
}

// PermStringToFlag maps camel- and snake case strings to the
// the corresponding permission flag.
func PermStringToFlag(perm string) (pf PermFlag, err error) {
switch perm {
switch strings.ToLower(perm) {
case "root":
pf = Root
case "send":
pf = Send
case "call":
pf = Call
case "create_contract":
case "createcontract", "create_contract":
pf = CreateContract
case "create_account":
case "createaccount", "create_account":
pf = CreateAccount
case "bond":
pf = Bond
case "name":
pf = Name
case "hasBase":
case "hasbase", "has_base":
pf = HasBase
case "setBase":
case "setbase", "set_base":
pf = SetBase
case "unsetBase":
case "unsetbase", "unset_base":
pf = UnsetBase
case "setGlobal":
case "setglobal", "set_global":
pf = SetGlobal
case "hasRole":
case "hasrole", "has_role":
pf = HasRole
case "addRole":
case "addrole", "add_role":
pf = AddRole
case "removeRole":
case "removerole", "rmrole", "rm_role":
pf = RmRole
default:
err = fmt.Errorf("Unknown permission %s", perm)
Expand Down

0 comments on commit 9efaad7

Please sign in to comment.