21 $currentUser = $this->_objectManager->get(\
Magento\Backend\Model\
Auth\Session::class)->getUser();
22 $userId = (int)$this->
getRequest()->getPost(
'user_id');
25 if ($currentUser->getId() == $userId) {
26 $this->messageManager->addError(
__(
'You cannot delete your own account.'));
27 $this->
_redirect(
'adminhtml/*/edit', [
'user_id' => $userId]);
31 $currentUserPassword = (string)$this->
getRequest()->getPost(UserEdit::CURRENT_USER_PASSWORD_FIELD);
32 if (empty($currentUserPassword)) {
34 __(
'The password entered for the current user is invalid. Verify the password and try again.')
37 $currentUser->performIdentityCheck($currentUserPassword);
39 $model = $this->_userFactory->create();
42 $this->messageManager->addSuccess(
__(
'You deleted the user.'));
45 }
catch (\Exception $e) {
46 $this->messageManager->addError($e->getMessage());
47 $this->
_redirect(
'adminhtml/*/edit', [
'user_id' => $this->
getRequest()->getParam(
'user_id')]);
51 $this->messageManager->addError(
__(
'We can\'t find a user to delete.'));
_redirect($path, $arguments=[])