mirror of
https://github.com/BookStackApp/BookStack.git
synced 2025-07-28 17:02:04 +03:00
Fixed name retrieval on missing users and added tests to cover along with some test helper methods
This commit is contained in:
@ -159,16 +159,14 @@ class UserController extends Controller
|
||||
$this->checkPermissionOr('user-delete', function () use ($id) {
|
||||
return $this->currentUser->id == $id;
|
||||
});
|
||||
$user = $this->userRepo->getById($id);
|
||||
|
||||
// Delete social accounts
|
||||
$user = $this->userRepo->getById($id);
|
||||
if ($this->userRepo->isOnlyAdmin($user)) {
|
||||
session()->flash('error', 'You cannot delete the only admin');
|
||||
return redirect($user->getEditUrl());
|
||||
}
|
||||
$this->userRepo->destroy($user);
|
||||
|
||||
$user->socialAccounts()->delete();
|
||||
$user->delete();
|
||||
return redirect('/users');
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user