func (u *User) AddRolesForEvent(roleEvent *permission.RoleEvent, contextValue string) error { roles, err := permission.ListRolesForEvent(roleEvent) if err != nil { return fmt.Errorf("unable to list roles: %s", err) } for _, r := range roles { err = u.AddRole(r.Name, contextValue) if err != nil { return fmt.Errorf("unable to add role: %s", err) } } return nil }
func (u *User) AddRolesForEvent(roleEvent *permission.RoleEvent, contextValue string) error { roles, err := permission.ListRolesForEvent(roleEvent) if err != nil { return errors.Wrap(err, "unable to list roles") } for _, r := range roles { err = u.AddRole(r.Name, contextValue) if err != nil { return errors.Wrap(err, "unable to add role") } } return nil }