fix(system): user.FindByID with nonexisting role
This commit is contained in:
@@ -81,7 +81,7 @@ func (r *role) FindByMemberID(userID uint64) ([]*types.Role, error) {
|
||||
rval := make([]*types.Role, 0)
|
||||
for _, id := range ids {
|
||||
mod, err := r.FindByID(id)
|
||||
if err != nil {
|
||||
if err != nil && err != ErrRoleNotFound {
|
||||
return nil, err
|
||||
}
|
||||
rval = append(rval, mod)
|
||||
|
||||
@@ -86,7 +86,13 @@ func (r *user) FindByID(id uint64) (*types.User, error) {
|
||||
if err := isFound(r.db().Get(mod, sql, id), mod.ID > 0, ErrUserNotFound); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return mod, r.prepare(mod, "roles")
|
||||
|
||||
err := r.prepare(mod, "roles")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return mod, nil
|
||||
}
|
||||
|
||||
func (r *user) FindByIDs(IDs ...uint64) (uu types.UserSet, err error) {
|
||||
|
||||
Reference in New Issue
Block a user