1
0
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:
Dan Brown
2015-12-15 19:27:36 +00:00
parent 123dc11583
commit af33156369
9 changed files with 90 additions and 14 deletions

View File

@ -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');
}
}