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

Commit

Permalink
Merge branch 'master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
benjaminbollen authored Apr 19, 2017
2 parents 565213a + 74cc19b commit 367a9fd
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions permission/types/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@

package types

// ConvertMapStringIntToPermissions converts a map of string-integer pairs and a slice of
// strings for the roles to an AccountPermissions type. The integer needs to be greater
// than zero to set the permission. For all unmentioned permissions the ZeroBasePermissions
// is defaulted to.
// TODO: [ben] re-evaluate the use of int for setting the permission.
func ConvertPermissionsMapAndRolesToAccountPermissions(permissions map[string]int, roles []string) (*AccountPermissions, error) {
// ConvertMapStringIntToPermissions converts a map of string-bool pairs and a slice of
// strings for the roles to an AccountPermissions type. If the value in the
// permissions map is true for a particular permission string then the permission
// will be set in the AccountsPermissions. For all unmentioned permissions the
// ZeroBasePermissions is defaulted to.
func ConvertPermissionsMapAndRolesToAccountPermissions(permissions map[string]bool, roles []string) (*AccountPermissions, error) {
var err error
accountPermissions := &AccountPermissions{}
accountPermissions.Base, err = convertPermissionsMapStringIntToBasePermissions(permissions)
Expand All @@ -30,9 +30,9 @@ func ConvertPermissionsMapAndRolesToAccountPermissions(permissions map[string]in
return accountPermissions, nil
}

// convertPermissionsMapStringIntToBasePermissions converts a map of string-integer pairs to
// BasePermissions.
func convertPermissionsMapStringIntToBasePermissions(permissions map[string]int) (BasePermissions, error) {
// convertPermissionsMapStringIntToBasePermissions converts a map of string-bool
// pairs to BasePermissions.
func convertPermissionsMapStringIntToBasePermissions(permissions map[string]bool) (BasePermissions, error) {
// initialise basePermissions as ZeroBasePermissions
basePermissions := ZeroBasePermissions

Expand All @@ -42,7 +42,7 @@ func convertPermissionsMapStringIntToBasePermissions(permissions map[string]int)
return basePermissions, err
}
// sets the permissions bitflag and the setbit flag for the permission.
basePermissions.Set(permissionsFlag, value > 0)
basePermissions.Set(permissionsFlag, value)
}

return basePermissions, nil
Expand Down

0 comments on commit 367a9fd

Please sign in to comment.