Skip to content
Snippets Groups Projects
Commit 367a9fdd authored by Benjamin Bollen's avatar Benjamin Bollen Committed by GitHub
Browse files

Merge branch 'master' into master

parents 565213a9 74cc19b2
No related branches found
No related tags found
No related merge requests found
...@@ -14,12 +14,12 @@ ...@@ -14,12 +14,12 @@
package types package types
// ConvertMapStringIntToPermissions converts a map of string-integer pairs and a slice of // ConvertMapStringIntToPermissions converts a map of string-bool pairs and a slice of
// strings for the roles to an AccountPermissions type. The integer needs to be greater // strings for the roles to an AccountPermissions type. If the value in the
// than zero to set the permission. For all unmentioned permissions the ZeroBasePermissions // permissions map is true for a particular permission string then the permission
// is defaulted to. // will be set in the AccountsPermissions. For all unmentioned permissions the
// TODO: [ben] re-evaluate the use of int for setting the permission. // ZeroBasePermissions is defaulted to.
func ConvertPermissionsMapAndRolesToAccountPermissions(permissions map[string]int, roles []string) (*AccountPermissions, error) { func ConvertPermissionsMapAndRolesToAccountPermissions(permissions map[string]bool, roles []string) (*AccountPermissions, error) {
var err error var err error
accountPermissions := &AccountPermissions{} accountPermissions := &AccountPermissions{}
accountPermissions.Base, err = convertPermissionsMapStringIntToBasePermissions(permissions) accountPermissions.Base, err = convertPermissionsMapStringIntToBasePermissions(permissions)
...@@ -30,9 +30,9 @@ func ConvertPermissionsMapAndRolesToAccountPermissions(permissions map[string]in ...@@ -30,9 +30,9 @@ func ConvertPermissionsMapAndRolesToAccountPermissions(permissions map[string]in
return accountPermissions, nil return accountPermissions, nil
} }
// convertPermissionsMapStringIntToBasePermissions converts a map of string-integer pairs to // convertPermissionsMapStringIntToBasePermissions converts a map of string-bool
// BasePermissions. // pairs to BasePermissions.
func convertPermissionsMapStringIntToBasePermissions(permissions map[string]int) (BasePermissions, error) { func convertPermissionsMapStringIntToBasePermissions(permissions map[string]bool) (BasePermissions, error) {
// initialise basePermissions as ZeroBasePermissions // initialise basePermissions as ZeroBasePermissions
basePermissions := ZeroBasePermissions basePermissions := ZeroBasePermissions
...@@ -42,7 +42,7 @@ func convertPermissionsMapStringIntToBasePermissions(permissions map[string]int) ...@@ -42,7 +42,7 @@ func convertPermissionsMapStringIntToBasePermissions(permissions map[string]int)
return basePermissions, err return basePermissions, err
} }
// sets the permissions bitflag and the setbit flag for the permission. // sets the permissions bitflag and the setbit flag for the permission.
basePermissions.Set(permissionsFlag, value > 0) basePermissions.Set(permissionsFlag, value)
} }
return basePermissions, nil return basePermissions, nil
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment