25 private $securityCookie;
33 private function getSecurityCookie()
36 return \Magento\Framework\App\ObjectManager::getInstance()->get(SecurityCookie::class);
38 return $this->securityCookie;
49 $userId = (int)$this->
getRequest()->getParam(
'user_id');
51 if (array_key_exists(
'form_key',
$data)) {
52 unset(
$data[
'form_key']);
60 $model = $this->_userFactory->create()->load($userId);
61 if ($userId &&
$model->isObjectNew()) {
62 $this->messageManager->addError(
__(
'This user no longer exists.'));
67 $userRoles = $this->
getRequest()->getParam(
'roles', []);
68 if (count($userRoles)) {
69 $model->setRoleId($userRoles[0]);
73 $currentUser = $this->_objectManager->get(\
Magento\Backend\Model\
Auth\Session::class)->getUser();
74 if ($userId == $currentUser->getId()
76 ->isValid(
$data[
'interface_locale'])
78 $this->_objectManager->get(
79 \
Magento\Backend\Model\Locale\Manager::class
80 )->switchBackendInterfaceLocale(
81 $data[
'interface_locale']
86 $currentUserPasswordField = \Magento\User\Block\User\Edit\Tab\Main::CURRENT_USER_PASSWORD_FIELD;
87 $isCurrentUserPasswordValid = isset(
$data[$currentUserPasswordField])
88 && !empty(
$data[$currentUserPasswordField]) && is_string(
$data[$currentUserPasswordField]);
90 if (!($isCurrentUserPasswordValid)) {
92 __(
'The password entered for the current user is invalid. Verify the password and try again.')
95 $currentUser->performIdentityCheck(
$data[$currentUserPasswordField]);
98 $this->messageManager->addSuccess(
__(
'You saved the user.'));
102 $model->sendNotificationEmailsIfRequired();
104 $this->_auth->logout();
105 $this->getSecurityCookie()->setLogoutReasonCookie(
106 \
Magento\
Security\Model\AdminSessionsManager::LOGOUT_REASON_USER_LOCKED
110 $this->messageManager->addErrorMessage($exception->getMessage());
112 $this->messageManager->addError(
113 __(
'The password entered for the current user is invalid. Verify the password and try again.')
117 $messages = $e->getMessages();
118 $this->messageManager->addMessages($messages);
121 if ($e->getMessage()) {
122 $this->messageManager->addError($e->getMessage());
_getAdminUserData(array $data)
_redirect($path, $arguments=[])
redirectToEdit(\Magento\User\Model\User $model, array $data)