Skip to content

Commit

Permalink
permission: PermStringToFlag extend camel- and snake case compatibili…
Browse files Browse the repository at this point in the history
…ty to create account and contract
  • Loading branch information
benjaminbollen committed Feb 23, 2017
1 parent 50aa5a1 commit 468b67b
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions permission/types/permissions.go
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,8 @@ 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 strings.ToLower(perm) {
case "root":
Expand All @@ -246,9 +248,9 @@ func PermStringToFlag(perm string) (pf PermFlag, err error) {
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
Expand All @@ -266,7 +268,7 @@ func PermStringToFlag(perm string) (pf PermFlag, err error) {
pf = HasRole
case "addrole", "add_role":
pf = AddRole
case "removerole", "rm_role":
case "removerole", "rmrole", "rm_role":
pf = RmRole
default:
err = fmt.Errorf("Unknown permission %s", perm)
Expand Down

0 comments on commit 468b67b

Please sign in to comment.