mirror of
https://github.com/BookStackApp/BookStack.git
synced 2025-05-21 23:38:39 +00:00
Added users-delete API endpoint
- Refactored some delete checks into repo. - Added tests to cover. - Moved some translations to align with activity/logging system.
This commit is contained in:
parent
d089623aac
commit
2cd7a48044
9 changed files with 101 additions and 22 deletions
app/Http/Controllers
|
@ -262,21 +262,7 @@ class UserController extends Controller
|
|||
$user = $this->userRepo->getById($id);
|
||||
$newOwnerId = $request->get('new_owner_id', null);
|
||||
|
||||
if ($this->userRepo->isOnlyAdmin($user)) {
|
||||
$this->showErrorNotification(trans('errors.users_cannot_delete_only_admin'));
|
||||
|
||||
return redirect($user->getEditUrl());
|
||||
}
|
||||
|
||||
if ($user->system_name === 'public') {
|
||||
$this->showErrorNotification(trans('errors.users_cannot_delete_guest'));
|
||||
|
||||
return redirect($user->getEditUrl());
|
||||
}
|
||||
|
||||
$this->userRepo->destroy($user, $newOwnerId);
|
||||
$this->showSuccessNotification(trans('settings.users_delete_success'));
|
||||
$this->logActivity(ActivityType::USER_DELETE, $user);
|
||||
|
||||
return redirect('/settings/users');
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue