From 1fa2e5b66df04e3c1da8c34b85f3a8cfdd73f627 Mon Sep 17 00:00:00 2001 From: Antonio Ramirez Date: Sun, 15 Oct 2017 23:00:21 +0200 Subject: [PATCH] Close #23 provide administrator with an option for user to reset its password. --- CHANGELOG.md | 1 + docs/installation/configuration-options.md | 5 ++++ src/User/Controller/AdminController.php | 27 ++++++++++++++++++---- src/User/Controller/RecoveryController.php | 2 +- src/User/Module.php | 4 ++++ src/User/resources/i18n/ca/usuario.php | 3 +++ src/User/resources/i18n/da/usuario.php | 3 +++ src/User/resources/i18n/de-DU/usuario.php | 3 +++ src/User/resources/i18n/de/usuario.php | 3 +++ src/User/resources/i18n/es/usuario.php | 13 +++++++---- src/User/resources/i18n/fa-IR/usuario.php | 3 +++ src/User/resources/i18n/fi/usuario.php | 3 +++ src/User/resources/i18n/fr/usuario.php | 3 +++ src/User/resources/i18n/hr/usuario.php | 3 +++ src/User/resources/i18n/hu/usuario.php | 3 +++ src/User/resources/i18n/it/usuario.php | 3 +++ src/User/resources/i18n/kk/usuario.php | 3 +++ src/User/resources/i18n/lt/usuario.php | 3 +++ src/User/resources/i18n/nl/usuario.php | 3 +++ src/User/resources/i18n/pl/usuario.php | 3 +++ src/User/resources/i18n/pt-BR/usuario.php | 3 +++ src/User/resources/i18n/pt-PT/usuario.php | 3 +++ src/User/resources/i18n/ro/usuario.php | 3 +++ src/User/resources/i18n/ru/usuario.php | 3 +++ src/User/resources/i18n/th/usuario.php | 3 +++ src/User/resources/i18n/tr_TR/usuario.php | 3 +++ src/User/resources/i18n/uk/usuario.php | 3 +++ src/User/resources/i18n/vi/usuario.php | 3 +++ src/User/resources/i18n/zh-CN/usuario.php | 3 +++ src/User/resources/views/admin/index.php | 20 +++++++++++++++- 30 files changed, 130 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 66e6cc0..cdb3774 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ # CHANGELOG ## 1.0.14 - Work in progress +- Enh #23: Provide administrator with an option to reset user password (tonydspaniard) - Enh #55: Provide google recaptcha mechanism (tonydspaniard) - Fix #20: Allow the assignment of a role on user creation via console (tonydspaniard) - Fix #59: Add instructions to add rbac migration path (tonydspaniard) diff --git a/docs/installation/configuration-options.md b/docs/installation/configuration-options.md index 99bc29c..2519ef2 100644 --- a/docs/installation/configuration-options.md +++ b/docs/installation/configuration-options.md @@ -43,6 +43,11 @@ If `true` it will allow users to login with unconfirmed emails. If `true` it will enable password recovery process. +#### allowAdminPasswordRecovery (type: `boolean`, default: `true`) + +If `true` and `allowPasswordRecovery` is false, it will enable administrator to send a password recovery email to a +user. + #### allowAccountDelete (type: `boolean`, default: `true`) If `true` users will be able to remove their own accounts. diff --git a/src/User/Controller/AdminController.php b/src/User/Controller/AdminController.php index 57cce4f..83d74fb 100644 --- a/src/User/Controller/AdminController.php +++ b/src/User/Controller/AdminController.php @@ -18,6 +18,7 @@ use Da\User\Model\Profile; use Da\User\Model\User; use Da\User\Query\UserQuery; use Da\User\Search\UserSearch; +use Da\User\Service\PasswordRecoveryService; use Da\User\Service\SwitchIdentityService; use Da\User\Service\UserBlockService; use Da\User\Service\UserConfirmationService; @@ -44,10 +45,10 @@ class AdminController extends Controller /** * AdminController constructor. * - * @param string $id - * @param Module $module + * @param string $id + * @param Module $module * @param UserQuery $userQuery - * @param array $config + * @param array $config */ public function __construct($id, Module $module, UserQuery $userQuery, array $config = []) { @@ -81,7 +82,8 @@ class AdminController extends Controller 'delete' => ['post'], 'confirm' => ['post'], 'block' => ['post'], - 'switch-identity' => ['post'] + 'switch-identity' => ['post'], + 'password-reset' => ['post'] ], ], 'access' => [ @@ -309,4 +311,21 @@ class AdminController extends Controller return $this->goHome(); } + + public function actionPasswordReset($id) + { + /** @var User $user */ + $user = $this->userQuery->where(['id' => $id])->one(); + $mailService = MailFactory::makeRecoveryMailerService($user->email); + if ($this->make(PasswordRecoveryService::class, [$user->email, $mailService])->run()) { + Yii::$app->getSession()->setFlash('success', Yii::t('usuario', 'Recovery message sent')); + } else { + Yii::$app->getSession()->setFlash( + 'danger', + Yii::t('usuario', 'Unable to send recovery message to the user') + ); + } + + return $this->redirect(['index']); + } } diff --git a/src/User/Controller/RecoveryController.php b/src/User/Controller/RecoveryController.php index ad1f931..1e8e86d 100644 --- a/src/User/Controller/RecoveryController.php +++ b/src/User/Controller/RecoveryController.php @@ -123,7 +123,7 @@ class RecoveryController extends Controller */ public function actionReset($id, $code) { - if (!$this->module->allowPasswordRecovery) { + if (!$this->module->allowPasswordRecovery && !$this->module->allowAdminPasswordRecovery) { throw new NotFoundHttpException(); } /** @var Token $token */ diff --git a/src/User/Module.php b/src/User/Module.php index 2ab8e72..53b54b5 100644 --- a/src/User/Module.php +++ b/src/User/Module.php @@ -56,6 +56,10 @@ class Module extends BaseModule * @var bool whether to enable password recovery or not */ public $allowPasswordRecovery = true; + /** + * @var bool whether to enable password recovery from the admin console + */ + public $allowAdminPasswordRecovery = true; /** * @var bool whether user can remove his account */ diff --git a/src/User/resources/i18n/ca/usuario.php b/src/User/resources/i18n/ca/usuario.php index 8a18a4e..09cc45d 100644 --- a/src/User/resources/i18n/ca/usuario.php +++ b/src/User/resources/i18n/ca/usuario.php @@ -35,6 +35,7 @@ return [ 'Are you sure you want to delete this user?' => '', 'Are you sure you want to switch to this user for the rest of this Session?' => '', 'Are you sure you want to unblock this user?' => '', + 'Are you sure you wish to send a password recovery email to this user?' => '', 'Are you sure? Deleted user can not be restored' => '', 'Are you sure? There is no going back' => '', 'Assignments' => '', @@ -161,6 +162,7 @@ return [ 'Rules' => '', 'Save' => '', 'Scan the QrCode with Google Authenticator App, then insert its temporary code on the box and submit.' => '', + 'Send password recovery email' => '', 'Sign in' => '', 'Sign up' => '', 'Something went wrong' => '', @@ -192,6 +194,7 @@ return [ 'Unable to disable two-factor authorization.' => '', 'Unable to remove authorization item.' => '', 'Unable to send confirmation link' => '', + 'Unable to send recovery message to the user' => '', 'Unable to update authorization item.' => '', 'Unable to update authorization rule.' => '', 'Unable to update block status.' => '', diff --git a/src/User/resources/i18n/da/usuario.php b/src/User/resources/i18n/da/usuario.php index 8a18a4e..09cc45d 100644 --- a/src/User/resources/i18n/da/usuario.php +++ b/src/User/resources/i18n/da/usuario.php @@ -35,6 +35,7 @@ return [ 'Are you sure you want to delete this user?' => '', 'Are you sure you want to switch to this user for the rest of this Session?' => '', 'Are you sure you want to unblock this user?' => '', + 'Are you sure you wish to send a password recovery email to this user?' => '', 'Are you sure? Deleted user can not be restored' => '', 'Are you sure? There is no going back' => '', 'Assignments' => '', @@ -161,6 +162,7 @@ return [ 'Rules' => '', 'Save' => '', 'Scan the QrCode with Google Authenticator App, then insert its temporary code on the box and submit.' => '', + 'Send password recovery email' => '', 'Sign in' => '', 'Sign up' => '', 'Something went wrong' => '', @@ -192,6 +194,7 @@ return [ 'Unable to disable two-factor authorization.' => '', 'Unable to remove authorization item.' => '', 'Unable to send confirmation link' => '', + 'Unable to send recovery message to the user' => '', 'Unable to update authorization item.' => '', 'Unable to update authorization rule.' => '', 'Unable to update block status.' => '', diff --git a/src/User/resources/i18n/de-DU/usuario.php b/src/User/resources/i18n/de-DU/usuario.php index 8a18a4e..09cc45d 100644 --- a/src/User/resources/i18n/de-DU/usuario.php +++ b/src/User/resources/i18n/de-DU/usuario.php @@ -35,6 +35,7 @@ return [ 'Are you sure you want to delete this user?' => '', 'Are you sure you want to switch to this user for the rest of this Session?' => '', 'Are you sure you want to unblock this user?' => '', + 'Are you sure you wish to send a password recovery email to this user?' => '', 'Are you sure? Deleted user can not be restored' => '', 'Are you sure? There is no going back' => '', 'Assignments' => '', @@ -161,6 +162,7 @@ return [ 'Rules' => '', 'Save' => '', 'Scan the QrCode with Google Authenticator App, then insert its temporary code on the box and submit.' => '', + 'Send password recovery email' => '', 'Sign in' => '', 'Sign up' => '', 'Something went wrong' => '', @@ -192,6 +194,7 @@ return [ 'Unable to disable two-factor authorization.' => '', 'Unable to remove authorization item.' => '', 'Unable to send confirmation link' => '', + 'Unable to send recovery message to the user' => '', 'Unable to update authorization item.' => '', 'Unable to update authorization rule.' => '', 'Unable to update block status.' => '', diff --git a/src/User/resources/i18n/de/usuario.php b/src/User/resources/i18n/de/usuario.php index b8d9cdf..389702b 100644 --- a/src/User/resources/i18n/de/usuario.php +++ b/src/User/resources/i18n/de/usuario.php @@ -19,6 +19,7 @@ return [ 'A message has been sent to your email address. It contains a confirmation link that you must click to complete registration.' => '', 'Are you sure you want to switch to this user for the rest of this Session?' => '', + 'Are you sure you wish to send a password recovery email to this user?' => '', 'Authentication rule class {0} can not be instantiated' => '', 'Authorization rule has been added.' => '', 'Authorization rule has been removed.' => '', @@ -48,6 +49,7 @@ return [ 'Rule {0} not found.' => '', 'Rules' => '', 'Scan the QrCode with Google Authenticator App, then insert its temporary code on the box and submit.' => '', + 'Send password recovery email' => '', 'Switch identities is disabled.' => '', 'The "recaptcha" component must be configured.' => '', 'The verification code is incorrect.' => '', @@ -61,6 +63,7 @@ return [ 'Two-factor code' => '', 'Unable to create new authorization rule.' => '', 'Unable to disable two-factor authorization.' => '', + 'Unable to send recovery message to the user' => '', 'Unable to update authorization rule.' => '', 'Update rule' => '', 'Updated at' => '', diff --git a/src/User/resources/i18n/es/usuario.php b/src/User/resources/i18n/es/usuario.php index c96215a..eb831f9 100644 --- a/src/User/resources/i18n/es/usuario.php +++ b/src/User/resources/i18n/es/usuario.php @@ -17,11 +17,9 @@ * NOTE: this file must be saved in UTF-8 encoding. */ return [ - 'Required "key" cannot be empty.' => 'El atributo "key" es obligatorio.', - 'Required "secret" cannot be empty.' => 'El atributo "secret" es obligatorio.', - 'The "recaptcha" component must be configured.' => 'El component "recaptcha" debe estar configurado.', - 'The verification code is incorrect.' => 'El código de verificación es incorrecto.', - '{0} cannot be blank.' => '{0} no puede estar vacío.', + 'Are you sure you wish to send a password recovery email to this user?' => 'Estás seguro de querer enviar un email de recuperación de contraseña a este usuario?', + 'Send password recovery email' => 'Enviar email de recuperación de contraseña', + 'Unable to send recovery message to the user' => 'Ha sido imposible enviar el email de recuperación de contraseña', '(not set)' => '(sin establecer)', 'A confirmation message has been sent to your new email address' => 'Se ha enviado un mensaje de confirmación a tu nueva dirección de correo electrónico', 'A message has been sent to your email address. It contains a confirmation link that you must click to complete registration.' => 'Un mensaje ha sido enviado a tu dirección de correo electrónico. Contiene un vínculo de confirmación que tienes que seguir para completar el registro.', @@ -152,6 +150,8 @@ return [ 'Registration time' => 'Hora de registro', 'Remember me next time' => 'Recuérdame la próxima vez', 'Request new confirmation message' => 'Solicita nuevo mensaje de confirmación', + 'Required "key" cannot be empty.' => 'El atributo "key" es obligatorio.', + 'Required "secret" cannot be empty.' => 'El atributo "secret" es obligatorio.', 'Reset your password' => 'Restablece contraseña', 'Role "{0}" not found. Creating it.' => 'Rol "{0}" no encontrado. Creándolo.', 'Roles' => 'Roles', @@ -170,7 +170,9 @@ return [ 'Switch identities is disabled.' => 'Personificación de usuarios deshabilitada.', 'Thank you for signing up on {0}' => 'Gracias por registrate en {0}', 'Thank you, registration is now complete.' => 'Gracias, el registro ha sido completado.', + 'The "recaptcha" component must be configured.' => 'El component "recaptcha" debe estar configurado.', 'The confirmation link is invalid or expired. Please try requesting a new one.' => 'El enlace de confirmación no es válido o ha caducado. Por favor, intenta a solicitar uno nuevo.', + 'The verification code is incorrect.' => 'El código de verificación es incorrecto.', 'There is neither role nor permission with name "{0}"' => 'No existe rol ni permiso con el nombre "{0}"', 'This account has already been connected to another user' => 'Esta cuenta ya está conectada con otro usuario', 'This email address has already been taken' => 'Esta cuenta de correo electrónico ya está siendo utilizada', @@ -239,4 +241,5 @@ return [ 'Your email address has been changed' => 'Tu cuenta de correo electrónico ha sido cambiada', 'Your profile has been updated' => 'Tu perfil ha sido actualizado', '{0, date, MMMM dd, YYYY HH:mm}' => '{0, date, MMMM dd, YYYY HH:mm}', + '{0} cannot be blank.' => '{0} no puede estar vacío.', ]; diff --git a/src/User/resources/i18n/fa-IR/usuario.php b/src/User/resources/i18n/fa-IR/usuario.php index 8a18a4e..09cc45d 100644 --- a/src/User/resources/i18n/fa-IR/usuario.php +++ b/src/User/resources/i18n/fa-IR/usuario.php @@ -35,6 +35,7 @@ return [ 'Are you sure you want to delete this user?' => '', 'Are you sure you want to switch to this user for the rest of this Session?' => '', 'Are you sure you want to unblock this user?' => '', + 'Are you sure you wish to send a password recovery email to this user?' => '', 'Are you sure? Deleted user can not be restored' => '', 'Are you sure? There is no going back' => '', 'Assignments' => '', @@ -161,6 +162,7 @@ return [ 'Rules' => '', 'Save' => '', 'Scan the QrCode with Google Authenticator App, then insert its temporary code on the box and submit.' => '', + 'Send password recovery email' => '', 'Sign in' => '', 'Sign up' => '', 'Something went wrong' => '', @@ -192,6 +194,7 @@ return [ 'Unable to disable two-factor authorization.' => '', 'Unable to remove authorization item.' => '', 'Unable to send confirmation link' => '', + 'Unable to send recovery message to the user' => '', 'Unable to update authorization item.' => '', 'Unable to update authorization rule.' => '', 'Unable to update block status.' => '', diff --git a/src/User/resources/i18n/fi/usuario.php b/src/User/resources/i18n/fi/usuario.php index 8a18a4e..09cc45d 100644 --- a/src/User/resources/i18n/fi/usuario.php +++ b/src/User/resources/i18n/fi/usuario.php @@ -35,6 +35,7 @@ return [ 'Are you sure you want to delete this user?' => '', 'Are you sure you want to switch to this user for the rest of this Session?' => '', 'Are you sure you want to unblock this user?' => '', + 'Are you sure you wish to send a password recovery email to this user?' => '', 'Are you sure? Deleted user can not be restored' => '', 'Are you sure? There is no going back' => '', 'Assignments' => '', @@ -161,6 +162,7 @@ return [ 'Rules' => '', 'Save' => '', 'Scan the QrCode with Google Authenticator App, then insert its temporary code on the box and submit.' => '', + 'Send password recovery email' => '', 'Sign in' => '', 'Sign up' => '', 'Something went wrong' => '', @@ -192,6 +194,7 @@ return [ 'Unable to disable two-factor authorization.' => '', 'Unable to remove authorization item.' => '', 'Unable to send confirmation link' => '', + 'Unable to send recovery message to the user' => '', 'Unable to update authorization item.' => '', 'Unable to update authorization rule.' => '', 'Unable to update block status.' => '', diff --git a/src/User/resources/i18n/fr/usuario.php b/src/User/resources/i18n/fr/usuario.php index 8a18a4e..09cc45d 100644 --- a/src/User/resources/i18n/fr/usuario.php +++ b/src/User/resources/i18n/fr/usuario.php @@ -35,6 +35,7 @@ return [ 'Are you sure you want to delete this user?' => '', 'Are you sure you want to switch to this user for the rest of this Session?' => '', 'Are you sure you want to unblock this user?' => '', + 'Are you sure you wish to send a password recovery email to this user?' => '', 'Are you sure? Deleted user can not be restored' => '', 'Are you sure? There is no going back' => '', 'Assignments' => '', @@ -161,6 +162,7 @@ return [ 'Rules' => '', 'Save' => '', 'Scan the QrCode with Google Authenticator App, then insert its temporary code on the box and submit.' => '', + 'Send password recovery email' => '', 'Sign in' => '', 'Sign up' => '', 'Something went wrong' => '', @@ -192,6 +194,7 @@ return [ 'Unable to disable two-factor authorization.' => '', 'Unable to remove authorization item.' => '', 'Unable to send confirmation link' => '', + 'Unable to send recovery message to the user' => '', 'Unable to update authorization item.' => '', 'Unable to update authorization rule.' => '', 'Unable to update block status.' => '', diff --git a/src/User/resources/i18n/hr/usuario.php b/src/User/resources/i18n/hr/usuario.php index 8a18a4e..09cc45d 100644 --- a/src/User/resources/i18n/hr/usuario.php +++ b/src/User/resources/i18n/hr/usuario.php @@ -35,6 +35,7 @@ return [ 'Are you sure you want to delete this user?' => '', 'Are you sure you want to switch to this user for the rest of this Session?' => '', 'Are you sure you want to unblock this user?' => '', + 'Are you sure you wish to send a password recovery email to this user?' => '', 'Are you sure? Deleted user can not be restored' => '', 'Are you sure? There is no going back' => '', 'Assignments' => '', @@ -161,6 +162,7 @@ return [ 'Rules' => '', 'Save' => '', 'Scan the QrCode with Google Authenticator App, then insert its temporary code on the box and submit.' => '', + 'Send password recovery email' => '', 'Sign in' => '', 'Sign up' => '', 'Something went wrong' => '', @@ -192,6 +194,7 @@ return [ 'Unable to disable two-factor authorization.' => '', 'Unable to remove authorization item.' => '', 'Unable to send confirmation link' => '', + 'Unable to send recovery message to the user' => '', 'Unable to update authorization item.' => '', 'Unable to update authorization rule.' => '', 'Unable to update block status.' => '', diff --git a/src/User/resources/i18n/hu/usuario.php b/src/User/resources/i18n/hu/usuario.php index 70331bc..9db8843 100644 --- a/src/User/resources/i18n/hu/usuario.php +++ b/src/User/resources/i18n/hu/usuario.php @@ -18,6 +18,7 @@ */ return [ 'A message has been sent to your email address. It contains a confirmation link that you must click to complete registration.' => '', + 'Are you sure you wish to send a password recovery email to this user?' => '', 'Awesome, almost there. Now you need to click the confirmation link sent to your new email address.' => '', 'Awesome, almost there. Now you need to click the confirmation link sent to your old email address.' => '', 'Cancel' => '', @@ -33,6 +34,7 @@ return [ 'Required "secret" cannot be empty.' => '', 'Role "{0}" not found. Creating it.' => '', 'Scan the QrCode with Google Authenticator App, then insert its temporary code on the box and submit.' => '', + 'Send password recovery email' => '', 'The "recaptcha" component must be configured.' => '', 'The verification code is incorrect.' => '', 'This will disable two-factor auth. Are you sure?' => '', @@ -44,6 +46,7 @@ return [ 'Two-factor authorization has been disabled.' => '', 'Two-factor code' => '', 'Unable to disable two-factor authorization.' => '', + 'Unable to send recovery message to the user' => '', 'User not found.' => '', 'Verification failed. Please, enter new code.' => '', 'We couldn\'t re-send the mail to confirm your address. Please, verify is the correct email or if it has been confirmed already.' => '', diff --git a/src/User/resources/i18n/it/usuario.php b/src/User/resources/i18n/it/usuario.php index 4cacb3a..3fa947f 100644 --- a/src/User/resources/i18n/it/usuario.php +++ b/src/User/resources/i18n/it/usuario.php @@ -18,6 +18,7 @@ */ return [ 'A message has been sent to your email address. It contains a confirmation link that you must click to complete registration.' => '', + 'Are you sure you wish to send a password recovery email to this user?' => '', 'Awesome, almost there. Now you need to click the confirmation link sent to your new email address.' => '', 'Awesome, almost there. Now you need to click the confirmation link sent to your old email address.' => '', 'Cancel' => '', @@ -33,6 +34,7 @@ return [ 'Required "secret" cannot be empty.' => '', 'Role "{0}" not found. Creating it.' => '', 'Scan the QrCode with Google Authenticator App, then insert its temporary code on the box and submit.' => '', + 'Send password recovery email' => '', 'The "recaptcha" component must be configured.' => '', 'The verification code is incorrect.' => '', 'This will disable two-factor auth. Are you sure?' => '', @@ -44,6 +46,7 @@ return [ 'Two-factor authorization has been disabled.' => '', 'Two-factor code' => '', 'Unable to disable two-factor authorization.' => '', + 'Unable to send recovery message to the user' => '', 'User not found.' => '', 'Verification failed. Please, enter new code.' => '', 'We couldn\'t re-send the mail to confirm your address. Please, verify is the correct email or if it has been confirmed already.' => '', diff --git a/src/User/resources/i18n/kk/usuario.php b/src/User/resources/i18n/kk/usuario.php index 8a18a4e..09cc45d 100644 --- a/src/User/resources/i18n/kk/usuario.php +++ b/src/User/resources/i18n/kk/usuario.php @@ -35,6 +35,7 @@ return [ 'Are you sure you want to delete this user?' => '', 'Are you sure you want to switch to this user for the rest of this Session?' => '', 'Are you sure you want to unblock this user?' => '', + 'Are you sure you wish to send a password recovery email to this user?' => '', 'Are you sure? Deleted user can not be restored' => '', 'Are you sure? There is no going back' => '', 'Assignments' => '', @@ -161,6 +162,7 @@ return [ 'Rules' => '', 'Save' => '', 'Scan the QrCode with Google Authenticator App, then insert its temporary code on the box and submit.' => '', + 'Send password recovery email' => '', 'Sign in' => '', 'Sign up' => '', 'Something went wrong' => '', @@ -192,6 +194,7 @@ return [ 'Unable to disable two-factor authorization.' => '', 'Unable to remove authorization item.' => '', 'Unable to send confirmation link' => '', + 'Unable to send recovery message to the user' => '', 'Unable to update authorization item.' => '', 'Unable to update authorization rule.' => '', 'Unable to update block status.' => '', diff --git a/src/User/resources/i18n/lt/usuario.php b/src/User/resources/i18n/lt/usuario.php index 8a18a4e..09cc45d 100644 --- a/src/User/resources/i18n/lt/usuario.php +++ b/src/User/resources/i18n/lt/usuario.php @@ -35,6 +35,7 @@ return [ 'Are you sure you want to delete this user?' => '', 'Are you sure you want to switch to this user for the rest of this Session?' => '', 'Are you sure you want to unblock this user?' => '', + 'Are you sure you wish to send a password recovery email to this user?' => '', 'Are you sure? Deleted user can not be restored' => '', 'Are you sure? There is no going back' => '', 'Assignments' => '', @@ -161,6 +162,7 @@ return [ 'Rules' => '', 'Save' => '', 'Scan the QrCode with Google Authenticator App, then insert its temporary code on the box and submit.' => '', + 'Send password recovery email' => '', 'Sign in' => '', 'Sign up' => '', 'Something went wrong' => '', @@ -192,6 +194,7 @@ return [ 'Unable to disable two-factor authorization.' => '', 'Unable to remove authorization item.' => '', 'Unable to send confirmation link' => '', + 'Unable to send recovery message to the user' => '', 'Unable to update authorization item.' => '', 'Unable to update authorization rule.' => '', 'Unable to update block status.' => '', diff --git a/src/User/resources/i18n/nl/usuario.php b/src/User/resources/i18n/nl/usuario.php index 8a18a4e..09cc45d 100644 --- a/src/User/resources/i18n/nl/usuario.php +++ b/src/User/resources/i18n/nl/usuario.php @@ -35,6 +35,7 @@ return [ 'Are you sure you want to delete this user?' => '', 'Are you sure you want to switch to this user for the rest of this Session?' => '', 'Are you sure you want to unblock this user?' => '', + 'Are you sure you wish to send a password recovery email to this user?' => '', 'Are you sure? Deleted user can not be restored' => '', 'Are you sure? There is no going back' => '', 'Assignments' => '', @@ -161,6 +162,7 @@ return [ 'Rules' => '', 'Save' => '', 'Scan the QrCode with Google Authenticator App, then insert its temporary code on the box and submit.' => '', + 'Send password recovery email' => '', 'Sign in' => '', 'Sign up' => '', 'Something went wrong' => '', @@ -192,6 +194,7 @@ return [ 'Unable to disable two-factor authorization.' => '', 'Unable to remove authorization item.' => '', 'Unable to send confirmation link' => '', + 'Unable to send recovery message to the user' => '', 'Unable to update authorization item.' => '', 'Unable to update authorization rule.' => '', 'Unable to update block status.' => '', diff --git a/src/User/resources/i18n/pl/usuario.php b/src/User/resources/i18n/pl/usuario.php index 5f503f5..0da67e2 100644 --- a/src/User/resources/i18n/pl/usuario.php +++ b/src/User/resources/i18n/pl/usuario.php @@ -17,12 +17,15 @@ * NOTE: this file must be saved in UTF-8 encoding. */ return [ + 'Are you sure you wish to send a password recovery email to this user?' => '', 'Cannot assign role "{0}" as the AuthManager is not configured on your console application.' => '', 'Required "key" cannot be empty.' => '', 'Required "secret" cannot be empty.' => '', 'Role "{0}" not found. Creating it.' => '', + 'Send password recovery email' => '', 'The "recaptcha" component must be configured.' => '', 'The verification code is incorrect.' => '', + 'Unable to send recovery message to the user' => '', '{0} cannot be blank.' => '', '(not set)' => '(nie podano)', 'A confirmation message has been sent to your new email address' => 'Potwierdzenie zostało wysłane na Twój nowy adres email', diff --git a/src/User/resources/i18n/pt-BR/usuario.php b/src/User/resources/i18n/pt-BR/usuario.php index 8a18a4e..09cc45d 100644 --- a/src/User/resources/i18n/pt-BR/usuario.php +++ b/src/User/resources/i18n/pt-BR/usuario.php @@ -35,6 +35,7 @@ return [ 'Are you sure you want to delete this user?' => '', 'Are you sure you want to switch to this user for the rest of this Session?' => '', 'Are you sure you want to unblock this user?' => '', + 'Are you sure you wish to send a password recovery email to this user?' => '', 'Are you sure? Deleted user can not be restored' => '', 'Are you sure? There is no going back' => '', 'Assignments' => '', @@ -161,6 +162,7 @@ return [ 'Rules' => '', 'Save' => '', 'Scan the QrCode with Google Authenticator App, then insert its temporary code on the box and submit.' => '', + 'Send password recovery email' => '', 'Sign in' => '', 'Sign up' => '', 'Something went wrong' => '', @@ -192,6 +194,7 @@ return [ 'Unable to disable two-factor authorization.' => '', 'Unable to remove authorization item.' => '', 'Unable to send confirmation link' => '', + 'Unable to send recovery message to the user' => '', 'Unable to update authorization item.' => '', 'Unable to update authorization rule.' => '', 'Unable to update block status.' => '', diff --git a/src/User/resources/i18n/pt-PT/usuario.php b/src/User/resources/i18n/pt-PT/usuario.php index 8a18a4e..09cc45d 100644 --- a/src/User/resources/i18n/pt-PT/usuario.php +++ b/src/User/resources/i18n/pt-PT/usuario.php @@ -35,6 +35,7 @@ return [ 'Are you sure you want to delete this user?' => '', 'Are you sure you want to switch to this user for the rest of this Session?' => '', 'Are you sure you want to unblock this user?' => '', + 'Are you sure you wish to send a password recovery email to this user?' => '', 'Are you sure? Deleted user can not be restored' => '', 'Are you sure? There is no going back' => '', 'Assignments' => '', @@ -161,6 +162,7 @@ return [ 'Rules' => '', 'Save' => '', 'Scan the QrCode with Google Authenticator App, then insert its temporary code on the box and submit.' => '', + 'Send password recovery email' => '', 'Sign in' => '', 'Sign up' => '', 'Something went wrong' => '', @@ -192,6 +194,7 @@ return [ 'Unable to disable two-factor authorization.' => '', 'Unable to remove authorization item.' => '', 'Unable to send confirmation link' => '', + 'Unable to send recovery message to the user' => '', 'Unable to update authorization item.' => '', 'Unable to update authorization rule.' => '', 'Unable to update block status.' => '', diff --git a/src/User/resources/i18n/ro/usuario.php b/src/User/resources/i18n/ro/usuario.php index 2ca4ae3..ed4b198 100644 --- a/src/User/resources/i18n/ro/usuario.php +++ b/src/User/resources/i18n/ro/usuario.php @@ -18,6 +18,7 @@ */ return [ 'A message has been sent to your email address. It contains a confirmation link that you must click to complete registration.' => '', + 'Are you sure you wish to send a password recovery email to this user?' => '', 'Awesome, almost there. Now you need to click the confirmation link sent to your new email address.' => '', 'Awesome, almost there. Now you need to click the confirmation link sent to your old email address.' => '', 'Cancel' => '', @@ -33,6 +34,7 @@ return [ 'Required "secret" cannot be empty.' => '', 'Role "{0}" not found. Creating it.' => '', 'Scan the QrCode with Google Authenticator App, then insert its temporary code on the box and submit.' => '', + 'Send password recovery email' => '', 'The "recaptcha" component must be configured.' => '', 'The verification code is incorrect.' => '', 'This will disable two-factor auth. Are you sure?' => '', @@ -44,6 +46,7 @@ return [ 'Two-factor authorization has been disabled.' => '', 'Two-factor code' => '', 'Unable to disable two-factor authorization.' => '', + 'Unable to send recovery message to the user' => '', 'User not found.' => '', 'Verification failed. Please, enter new code.' => '', 'We couldn\'t re-send the mail to confirm your address. Please, verify is the correct email or if it has been confirmed already.' => '', diff --git a/src/User/resources/i18n/ru/usuario.php b/src/User/resources/i18n/ru/usuario.php index ae3e0fe..6152337 100644 --- a/src/User/resources/i18n/ru/usuario.php +++ b/src/User/resources/i18n/ru/usuario.php @@ -18,6 +18,7 @@ */ return [ 'A message has been sent to your email address. It contains a confirmation link that you must click to complete registration.' => '', + 'Are you sure you wish to send a password recovery email to this user?' => '', 'Awesome, almost there. Now you need to click the confirmation link sent to your new email address.' => '', 'Awesome, almost there. Now you need to click the confirmation link sent to your old email address.' => '', 'Cancel' => '', @@ -33,6 +34,7 @@ return [ 'Required "secret" cannot be empty.' => '', 'Role "{0}" not found. Creating it.' => '', 'Scan the QrCode with Google Authenticator App, then insert its temporary code on the box and submit.' => '', + 'Send password recovery email' => '', 'The "recaptcha" component must be configured.' => '', 'The verification code is incorrect.' => '', 'This will disable two-factor auth. Are you sure?' => '', @@ -44,6 +46,7 @@ return [ 'Two-factor authorization has been disabled.' => '', 'Two-factor code' => '', 'Unable to disable two-factor authorization.' => '', + 'Unable to send recovery message to the user' => '', 'User not found.' => '', 'Verification failed. Please, enter new code.' => '', 'We couldn\'t re-send the mail to confirm your address. Please, verify is the correct email or if it has been confirmed already.' => '', diff --git a/src/User/resources/i18n/th/usuario.php b/src/User/resources/i18n/th/usuario.php index 8a18a4e..09cc45d 100644 --- a/src/User/resources/i18n/th/usuario.php +++ b/src/User/resources/i18n/th/usuario.php @@ -35,6 +35,7 @@ return [ 'Are you sure you want to delete this user?' => '', 'Are you sure you want to switch to this user for the rest of this Session?' => '', 'Are you sure you want to unblock this user?' => '', + 'Are you sure you wish to send a password recovery email to this user?' => '', 'Are you sure? Deleted user can not be restored' => '', 'Are you sure? There is no going back' => '', 'Assignments' => '', @@ -161,6 +162,7 @@ return [ 'Rules' => '', 'Save' => '', 'Scan the QrCode with Google Authenticator App, then insert its temporary code on the box and submit.' => '', + 'Send password recovery email' => '', 'Sign in' => '', 'Sign up' => '', 'Something went wrong' => '', @@ -192,6 +194,7 @@ return [ 'Unable to disable two-factor authorization.' => '', 'Unable to remove authorization item.' => '', 'Unable to send confirmation link' => '', + 'Unable to send recovery message to the user' => '', 'Unable to update authorization item.' => '', 'Unable to update authorization rule.' => '', 'Unable to update block status.' => '', diff --git a/src/User/resources/i18n/tr_TR/usuario.php b/src/User/resources/i18n/tr_TR/usuario.php index 8a18a4e..09cc45d 100644 --- a/src/User/resources/i18n/tr_TR/usuario.php +++ b/src/User/resources/i18n/tr_TR/usuario.php @@ -35,6 +35,7 @@ return [ 'Are you sure you want to delete this user?' => '', 'Are you sure you want to switch to this user for the rest of this Session?' => '', 'Are you sure you want to unblock this user?' => '', + 'Are you sure you wish to send a password recovery email to this user?' => '', 'Are you sure? Deleted user can not be restored' => '', 'Are you sure? There is no going back' => '', 'Assignments' => '', @@ -161,6 +162,7 @@ return [ 'Rules' => '', 'Save' => '', 'Scan the QrCode with Google Authenticator App, then insert its temporary code on the box and submit.' => '', + 'Send password recovery email' => '', 'Sign in' => '', 'Sign up' => '', 'Something went wrong' => '', @@ -192,6 +194,7 @@ return [ 'Unable to disable two-factor authorization.' => '', 'Unable to remove authorization item.' => '', 'Unable to send confirmation link' => '', + 'Unable to send recovery message to the user' => '', 'Unable to update authorization item.' => '', 'Unable to update authorization rule.' => '', 'Unable to update block status.' => '', diff --git a/src/User/resources/i18n/uk/usuario.php b/src/User/resources/i18n/uk/usuario.php index 8a18a4e..09cc45d 100644 --- a/src/User/resources/i18n/uk/usuario.php +++ b/src/User/resources/i18n/uk/usuario.php @@ -35,6 +35,7 @@ return [ 'Are you sure you want to delete this user?' => '', 'Are you sure you want to switch to this user for the rest of this Session?' => '', 'Are you sure you want to unblock this user?' => '', + 'Are you sure you wish to send a password recovery email to this user?' => '', 'Are you sure? Deleted user can not be restored' => '', 'Are you sure? There is no going back' => '', 'Assignments' => '', @@ -161,6 +162,7 @@ return [ 'Rules' => '', 'Save' => '', 'Scan the QrCode with Google Authenticator App, then insert its temporary code on the box and submit.' => '', + 'Send password recovery email' => '', 'Sign in' => '', 'Sign up' => '', 'Something went wrong' => '', @@ -192,6 +194,7 @@ return [ 'Unable to disable two-factor authorization.' => '', 'Unable to remove authorization item.' => '', 'Unable to send confirmation link' => '', + 'Unable to send recovery message to the user' => '', 'Unable to update authorization item.' => '', 'Unable to update authorization rule.' => '', 'Unable to update block status.' => '', diff --git a/src/User/resources/i18n/vi/usuario.php b/src/User/resources/i18n/vi/usuario.php index 8a18a4e..09cc45d 100644 --- a/src/User/resources/i18n/vi/usuario.php +++ b/src/User/resources/i18n/vi/usuario.php @@ -35,6 +35,7 @@ return [ 'Are you sure you want to delete this user?' => '', 'Are you sure you want to switch to this user for the rest of this Session?' => '', 'Are you sure you want to unblock this user?' => '', + 'Are you sure you wish to send a password recovery email to this user?' => '', 'Are you sure? Deleted user can not be restored' => '', 'Are you sure? There is no going back' => '', 'Assignments' => '', @@ -161,6 +162,7 @@ return [ 'Rules' => '', 'Save' => '', 'Scan the QrCode with Google Authenticator App, then insert its temporary code on the box and submit.' => '', + 'Send password recovery email' => '', 'Sign in' => '', 'Sign up' => '', 'Something went wrong' => '', @@ -192,6 +194,7 @@ return [ 'Unable to disable two-factor authorization.' => '', 'Unable to remove authorization item.' => '', 'Unable to send confirmation link' => '', + 'Unable to send recovery message to the user' => '', 'Unable to update authorization item.' => '', 'Unable to update authorization rule.' => '', 'Unable to update block status.' => '', diff --git a/src/User/resources/i18n/zh-CN/usuario.php b/src/User/resources/i18n/zh-CN/usuario.php index 8a18a4e..09cc45d 100644 --- a/src/User/resources/i18n/zh-CN/usuario.php +++ b/src/User/resources/i18n/zh-CN/usuario.php @@ -35,6 +35,7 @@ return [ 'Are you sure you want to delete this user?' => '', 'Are you sure you want to switch to this user for the rest of this Session?' => '', 'Are you sure you want to unblock this user?' => '', + 'Are you sure you wish to send a password recovery email to this user?' => '', 'Are you sure? Deleted user can not be restored' => '', 'Are you sure? There is no going back' => '', 'Assignments' => '', @@ -161,6 +162,7 @@ return [ 'Rules' => '', 'Save' => '', 'Scan the QrCode with Google Authenticator App, then insert its temporary code on the box and submit.' => '', + 'Send password recovery email' => '', 'Sign in' => '', 'Sign up' => '', 'Something went wrong' => '', @@ -192,6 +194,7 @@ return [ 'Unable to disable two-factor authorization.' => '', 'Unable to remove authorization item.' => '', 'Unable to send confirmation link' => '', + 'Unable to send recovery message to the user' => '', 'Unable to update authorization item.' => '', 'Unable to update authorization rule.' => '', 'Unable to update block status.' => '', diff --git a/src/User/resources/views/admin/index.php b/src/User/resources/views/admin/index.php index 97cee7c..cf2bf3c 100644 --- a/src/User/resources/views/admin/index.php +++ b/src/User/resources/views/admin/index.php @@ -121,7 +121,7 @@ $module = Yii::$app->getModule('user'); ], [ 'class' => 'yii\grid\ActionColumn', - 'template' => '{switch} {update} {delete}', + 'template' => '{switch} {reset} {update} {delete}', 'buttons' => [ 'switch' => function ($url, $model) use ($module) { if ($model->id != Yii::$app->user->id && $module->enableSwitchIdentities) { @@ -139,6 +139,24 @@ $module = Yii::$app->getModule('user'); ); } + return null; + }, + 'reset' => function ($url, $model) use ($module) { + if(!$module->allowPasswordRecovery && $module->allowAdminPasswordRecovery) { + return Html::a( + '', + ['/user/admin/password-reset', 'id' => $model->id], + [ + 'title' => Yii::t('usuario', 'Send password recovery email'), + 'data-confirm' => Yii::t( + 'usuario', + 'Are you sure you wish to send a password recovery email to this user?' + ), + 'data-method' => 'POST', + ] + ); + } + return null; } ]