Moved validator
Signed-off-by: snipe <snipe@snipe.net>
This commit is contained in:
parent
e1eb457f3d
commit
bb96a190fd
1 changed files with 7 additions and 4 deletions
|
@ -496,17 +496,20 @@ class UsersController extends Controller
|
||||||
// Check if the request has groups passed and has a value, AND that the user us a superuser
|
// Check if the request has groups passed and has a value, AND that the user us a superuser
|
||||||
if (($request->has('groups')) && (Auth::user()->isSuperUser())) {
|
if (($request->has('groups')) && (Auth::user()->isSuperUser())) {
|
||||||
|
|
||||||
$validator = Validator::make($request->all(), [
|
$validator = Validator::make($request->only('groups'), [
|
||||||
'groups.*' => 'integer|exists:permission_groups,id',
|
'groups.*' => 'integer|exists:permission_groups,id',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
if ($validator->fails()) {
|
||||||
|
return response()->json(Helper::formatStandardApiResponse('error', null, $validator->errors()));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Sync the groups since the user is a superuser and the groups pass validation
|
||||||
$user->groups()->sync($request->input('groups'));
|
$user->groups()->sync($request->input('groups'));
|
||||||
|
|
||||||
if ($validator->fails()) {
|
|
||||||
return response()->json(Helper::formatStandardApiResponse('error', null, $user->getErrors()));
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return response()->json(Helper::formatStandardApiResponse('success', (new UsersTransformer)->transformUser($user), trans('admin/users/message.success.update')));
|
return response()->json(Helper::formatStandardApiResponse('success', (new UsersTransformer)->transformUser($user), trans('admin/users/message.success.update')));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue