From a5a9bd56b7fef8dfe8c2a9e90aac50ce7371da01 Mon Sep 17 00:00:00 2001
From: Frederic Guillot <fred@kanboard.net>
Date: Sun, 29 Jan 2017 20:47:00 -0500
Subject: Improve forget password behaviour

Notify the user that an email has been sent or not.
---
 app/Controller/PasswordResetController.php | 8 ++++++--
 app/Locale/bs_BA/translations.php          | 4 ++++
 app/Locale/cs_CZ/translations.php          | 4 ++++
 app/Locale/da_DK/translations.php          | 4 ++++
 app/Locale/de_DE/translations.php          | 4 ++++
 app/Locale/el_GR/translations.php          | 4 ++++
 app/Locale/es_ES/translations.php          | 4 ++++
 app/Locale/fi_FI/translations.php          | 4 ++++
 app/Locale/fr_FR/translations.php          | 4 ++++
 app/Locale/hu_HU/translations.php          | 4 ++++
 app/Locale/id_ID/translations.php          | 4 ++++
 app/Locale/it_IT/translations.php          | 4 ++++
 app/Locale/ja_JP/translations.php          | 4 ++++
 app/Locale/ko_KR/translations.php          | 4 ++++
 app/Locale/my_MY/translations.php          | 4 ++++
 app/Locale/nb_NO/translations.php          | 4 ++++
 app/Locale/nl_NL/translations.php          | 4 ++++
 app/Locale/pl_PL/translations.php          | 4 ++++
 app/Locale/pt_BR/translations.php          | 4 ++++
 app/Locale/pt_PT/translations.php          | 4 ++++
 app/Locale/ru_RU/translations.php          | 4 ++++
 app/Locale/sr_Latn_RS/translations.php     | 4 ++++
 app/Locale/sv_SE/translations.php          | 4 ++++
 app/Locale/th_TH/translations.php          | 4 ++++
 app/Locale/tr_TR/translations.php          | 4 ++++
 app/Locale/zh_CN/translations.php          | 4 ++++
 app/Template/password_reset/create.php     | 1 +
 27 files changed, 107 insertions(+), 2 deletions(-)

(limited to 'app')

diff --git a/app/Controller/PasswordResetController.php b/app/Controller/PasswordResetController.php
index 6189f946..cc0755ca 100644
--- a/app/Controller/PasswordResetController.php
+++ b/app/Controller/PasswordResetController.php
@@ -104,7 +104,7 @@ class PasswordResetController extends BaseController
      *
      * @param string $username
      */
-    private function sendEmail($username)
+    protected function sendEmail($username)
     {
         $token = $this->passwordResetModel->create($username);
 
@@ -117,13 +117,17 @@ class PasswordResetController extends BaseController
                 t('Password Reset for Kanboard'),
                 $this->template->render('password_reset/email', array('token' => $token))
             );
+
+            $this->flash->success(t('A link to reset your password has been sent by email.'));
+        } else {
+            $this->flash->failure(t('Unfortunately, we are unable to reset your password. Did you entered a valid username? Do you have an email address in your profile?'));
         }
     }
 
     /**
      * Check feature availability
      */
-    private function checkActivation()
+    protected function checkActivation()
     {
         if ($this->configModel->get('password_reset', 0) == 0) {
             throw AccessForbiddenException::getInstance()->withoutLayout();
diff --git a/app/Locale/bs_BA/translations.php b/app/Locale/bs_BA/translations.php
index e689439c..3174d450 100644
--- a/app/Locale/bs_BA/translations.php
+++ b/app/Locale/bs_BA/translations.php
@@ -1307,4 +1307,8 @@ return array(
     // 'Credentials' => '',
     // 'New user' => '',
     // 'This username is already taken' => '',
+    // 'A link to reset your password has been sent by email.' => '',
+    // 'Your profile must have a valid email address.' => '',
+    // 'Unfortunately, we are unable to reset your password. Did you entered a valid username? Do you have an email address in your profile?' => '',
+    // 'TRL - Turkish Lira' => '',
 );
diff --git a/app/Locale/cs_CZ/translations.php b/app/Locale/cs_CZ/translations.php
index 6299f514..e152db9f 100644
--- a/app/Locale/cs_CZ/translations.php
+++ b/app/Locale/cs_CZ/translations.php
@@ -1307,4 +1307,8 @@ return array(
     // 'Credentials' => '',
     // 'New user' => '',
     // 'This username is already taken' => '',
+    // 'A link to reset your password has been sent by email.' => '',
+    // 'Your profile must have a valid email address.' => '',
+    // 'Unfortunately, we are unable to reset your password. Did you entered a valid username? Do you have an email address in your profile?' => '',
+    // 'TRL - Turkish Lira' => '',
 );
diff --git a/app/Locale/da_DK/translations.php b/app/Locale/da_DK/translations.php
index 87d65e87..a38a20d7 100644
--- a/app/Locale/da_DK/translations.php
+++ b/app/Locale/da_DK/translations.php
@@ -1307,4 +1307,8 @@ return array(
     // 'Credentials' => '',
     // 'New user' => '',
     // 'This username is already taken' => '',
+    // 'A link to reset your password has been sent by email.' => '',
+    // 'Your profile must have a valid email address.' => '',
+    // 'Unfortunately, we are unable to reset your password. Did you entered a valid username? Do you have an email address in your profile?' => '',
+    // 'TRL - Turkish Lira' => '',
 );
diff --git a/app/Locale/de_DE/translations.php b/app/Locale/de_DE/translations.php
index adefbf13..13cdf6bf 100644
--- a/app/Locale/de_DE/translations.php
+++ b/app/Locale/de_DE/translations.php
@@ -1307,4 +1307,8 @@ return array(
     'Credentials' => 'Anmeldeinformationen',
     'New user' => 'Neuer Benutzer',
     'This username is already taken' => 'Dieser Benutzername ist bereits vergeben',
+    // 'A link to reset your password has been sent by email.' => '',
+    // 'Your profile must have a valid email address.' => '',
+    // 'Unfortunately, we are unable to reset your password. Did you entered a valid username? Do you have an email address in your profile?' => '',
+    // 'TRL - Turkish Lira' => '',
 );
diff --git a/app/Locale/el_GR/translations.php b/app/Locale/el_GR/translations.php
index 959b32d2..c2760407 100644
--- a/app/Locale/el_GR/translations.php
+++ b/app/Locale/el_GR/translations.php
@@ -1307,4 +1307,8 @@ return array(
     // 'Credentials' => '',
     // 'New user' => '',
     // 'This username is already taken' => '',
+    // 'A link to reset your password has been sent by email.' => '',
+    // 'Your profile must have a valid email address.' => '',
+    // 'Unfortunately, we are unable to reset your password. Did you entered a valid username? Do you have an email address in your profile?' => '',
+    // 'TRL - Turkish Lira' => '',
 );
diff --git a/app/Locale/es_ES/translations.php b/app/Locale/es_ES/translations.php
index 5f5d71e1..3fa4c3a8 100644
--- a/app/Locale/es_ES/translations.php
+++ b/app/Locale/es_ES/translations.php
@@ -1307,4 +1307,8 @@ return array(
     // 'Credentials' => '',
     // 'New user' => '',
     // 'This username is already taken' => '',
+    // 'A link to reset your password has been sent by email.' => '',
+    // 'Your profile must have a valid email address.' => '',
+    // 'Unfortunately, we are unable to reset your password. Did you entered a valid username? Do you have an email address in your profile?' => '',
+    // 'TRL - Turkish Lira' => '',
 );
diff --git a/app/Locale/fi_FI/translations.php b/app/Locale/fi_FI/translations.php
index 685858aa..f37abc55 100644
--- a/app/Locale/fi_FI/translations.php
+++ b/app/Locale/fi_FI/translations.php
@@ -1307,4 +1307,8 @@ return array(
     // 'Credentials' => '',
     // 'New user' => '',
     // 'This username is already taken' => '',
+    // 'A link to reset your password has been sent by email.' => '',
+    // 'Your profile must have a valid email address.' => '',
+    // 'Unfortunately, we are unable to reset your password. Did you entered a valid username? Do you have an email address in your profile?' => '',
+    // 'TRL - Turkish Lira' => '',
 );
diff --git a/app/Locale/fr_FR/translations.php b/app/Locale/fr_FR/translations.php
index 824519f9..ce2e8a46 100644
--- a/app/Locale/fr_FR/translations.php
+++ b/app/Locale/fr_FR/translations.php
@@ -1307,4 +1307,8 @@ return array(
     'Credentials' => 'Informations d\'identification',
     'New user' => 'Nouvel utilisateur',
     'This username is already taken' => 'Ce nom d\'utilisateur est déjà pris',
+    'A link to reset your password has been sent by email.' => 'Un lien pour réinitialiser votre mot de passe a été envoyé par email.',
+    'Your profile must have a valid email address.' => 'Votre profil doit avoir une adresse e-mail valide.',
+    'Unfortunately, we are unable to reset your password. Did you entered a valid username? Do you have an email address in your profile?' => 'Malheureusement, nous ne pouvons pas réinitialiser votre mot de passe. Avez-vous saisi un nom d\'utilisateur valide ? Avez-vous une adresse e-mail dans votre profil ?',
+    'TRL - Turkish Lira' => 'TRL - Livre turque',
 );
diff --git a/app/Locale/hu_HU/translations.php b/app/Locale/hu_HU/translations.php
index 4b8dedbe..57bea247 100644
--- a/app/Locale/hu_HU/translations.php
+++ b/app/Locale/hu_HU/translations.php
@@ -1307,4 +1307,8 @@ return array(
     // 'Credentials' => '',
     // 'New user' => '',
     // 'This username is already taken' => '',
+    // 'A link to reset your password has been sent by email.' => '',
+    // 'Your profile must have a valid email address.' => '',
+    // 'Unfortunately, we are unable to reset your password. Did you entered a valid username? Do you have an email address in your profile?' => '',
+    // 'TRL - Turkish Lira' => '',
 );
diff --git a/app/Locale/id_ID/translations.php b/app/Locale/id_ID/translations.php
index 45c93b06..4c2bab4f 100644
--- a/app/Locale/id_ID/translations.php
+++ b/app/Locale/id_ID/translations.php
@@ -1307,4 +1307,8 @@ return array(
     // 'Credentials' => '',
     // 'New user' => '',
     // 'This username is already taken' => '',
+    // 'A link to reset your password has been sent by email.' => '',
+    // 'Your profile must have a valid email address.' => '',
+    // 'Unfortunately, we are unable to reset your password. Did you entered a valid username? Do you have an email address in your profile?' => '',
+    // 'TRL - Turkish Lira' => '',
 );
diff --git a/app/Locale/it_IT/translations.php b/app/Locale/it_IT/translations.php
index f7c6c5ee..8a73ceeb 100644
--- a/app/Locale/it_IT/translations.php
+++ b/app/Locale/it_IT/translations.php
@@ -1307,4 +1307,8 @@ return array(
     // 'Credentials' => '',
     // 'New user' => '',
     // 'This username is already taken' => '',
+    // 'A link to reset your password has been sent by email.' => '',
+    // 'Your profile must have a valid email address.' => '',
+    // 'Unfortunately, we are unable to reset your password. Did you entered a valid username? Do you have an email address in your profile?' => '',
+    // 'TRL - Turkish Lira' => '',
 );
diff --git a/app/Locale/ja_JP/translations.php b/app/Locale/ja_JP/translations.php
index e747c320..8ce0c9fa 100644
--- a/app/Locale/ja_JP/translations.php
+++ b/app/Locale/ja_JP/translations.php
@@ -1307,4 +1307,8 @@ return array(
     // 'Credentials' => '',
     // 'New user' => '',
     // 'This username is already taken' => '',
+    // 'A link to reset your password has been sent by email.' => '',
+    // 'Your profile must have a valid email address.' => '',
+    // 'Unfortunately, we are unable to reset your password. Did you entered a valid username? Do you have an email address in your profile?' => '',
+    // 'TRL - Turkish Lira' => '',
 );
diff --git a/app/Locale/ko_KR/translations.php b/app/Locale/ko_KR/translations.php
index e1825ad7..b3fe859e 100644
--- a/app/Locale/ko_KR/translations.php
+++ b/app/Locale/ko_KR/translations.php
@@ -1307,4 +1307,8 @@ return array(
     // 'Credentials' => '',
     // 'New user' => '',
     // 'This username is already taken' => '',
+    // 'A link to reset your password has been sent by email.' => '',
+    // 'Your profile must have a valid email address.' => '',
+    // 'Unfortunately, we are unable to reset your password. Did you entered a valid username? Do you have an email address in your profile?' => '',
+    // 'TRL - Turkish Lira' => '',
 );
diff --git a/app/Locale/my_MY/translations.php b/app/Locale/my_MY/translations.php
index 641dfefa..0d694782 100644
--- a/app/Locale/my_MY/translations.php
+++ b/app/Locale/my_MY/translations.php
@@ -1307,4 +1307,8 @@ return array(
     // 'Credentials' => '',
     // 'New user' => '',
     // 'This username is already taken' => '',
+    // 'A link to reset your password has been sent by email.' => '',
+    // 'Your profile must have a valid email address.' => '',
+    // 'Unfortunately, we are unable to reset your password. Did you entered a valid username? Do you have an email address in your profile?' => '',
+    // 'TRL - Turkish Lira' => '',
 );
diff --git a/app/Locale/nb_NO/translations.php b/app/Locale/nb_NO/translations.php
index da7e6508..7f563358 100644
--- a/app/Locale/nb_NO/translations.php
+++ b/app/Locale/nb_NO/translations.php
@@ -1307,4 +1307,8 @@ return array(
     // 'Credentials' => '',
     // 'New user' => '',
     // 'This username is already taken' => '',
+    // 'A link to reset your password has been sent by email.' => '',
+    // 'Your profile must have a valid email address.' => '',
+    // 'Unfortunately, we are unable to reset your password. Did you entered a valid username? Do you have an email address in your profile?' => '',
+    // 'TRL - Turkish Lira' => '',
 );
diff --git a/app/Locale/nl_NL/translations.php b/app/Locale/nl_NL/translations.php
index 140c0406..37427071 100644
--- a/app/Locale/nl_NL/translations.php
+++ b/app/Locale/nl_NL/translations.php
@@ -1307,4 +1307,8 @@ return array(
     // 'Credentials' => '',
     // 'New user' => '',
     // 'This username is already taken' => '',
+    // 'A link to reset your password has been sent by email.' => '',
+    // 'Your profile must have a valid email address.' => '',
+    // 'Unfortunately, we are unable to reset your password. Did you entered a valid username? Do you have an email address in your profile?' => '',
+    // 'TRL - Turkish Lira' => '',
 );
diff --git a/app/Locale/pl_PL/translations.php b/app/Locale/pl_PL/translations.php
index 16988195..a3b0018d 100644
--- a/app/Locale/pl_PL/translations.php
+++ b/app/Locale/pl_PL/translations.php
@@ -1307,4 +1307,8 @@ return array(
     // 'Credentials' => '',
     // 'New user' => '',
     // 'This username is already taken' => '',
+    // 'A link to reset your password has been sent by email.' => '',
+    // 'Your profile must have a valid email address.' => '',
+    // 'Unfortunately, we are unable to reset your password. Did you entered a valid username? Do you have an email address in your profile?' => '',
+    // 'TRL - Turkish Lira' => '',
 );
diff --git a/app/Locale/pt_BR/translations.php b/app/Locale/pt_BR/translations.php
index ef8fc4c9..0de6ab2b 100644
--- a/app/Locale/pt_BR/translations.php
+++ b/app/Locale/pt_BR/translations.php
@@ -1307,4 +1307,8 @@ return array(
     // 'Credentials' => '',
     // 'New user' => '',
     // 'This username is already taken' => '',
+    // 'A link to reset your password has been sent by email.' => '',
+    // 'Your profile must have a valid email address.' => '',
+    // 'Unfortunately, we are unable to reset your password. Did you entered a valid username? Do you have an email address in your profile?' => '',
+    // 'TRL - Turkish Lira' => '',
 );
diff --git a/app/Locale/pt_PT/translations.php b/app/Locale/pt_PT/translations.php
index c4e14ed3..d7a8b74d 100644
--- a/app/Locale/pt_PT/translations.php
+++ b/app/Locale/pt_PT/translations.php
@@ -1307,4 +1307,8 @@ return array(
     'Credentials' => 'Credenciais',
     'New user' => 'Novo utilizador',
     'This username is already taken' => 'Este nome de usuário já foi utilizado',
+    // 'A link to reset your password has been sent by email.' => '',
+    // 'Your profile must have a valid email address.' => '',
+    // 'Unfortunately, we are unable to reset your password. Did you entered a valid username? Do you have an email address in your profile?' => '',
+    // 'TRL - Turkish Lira' => '',
 );
diff --git a/app/Locale/ru_RU/translations.php b/app/Locale/ru_RU/translations.php
index 7bf57fb2..d9b9d4d2 100644
--- a/app/Locale/ru_RU/translations.php
+++ b/app/Locale/ru_RU/translations.php
@@ -1307,4 +1307,8 @@ return array(
     // 'Credentials' => '',
     'New user' => 'Добавить пользователя',
     // 'This username is already taken' => '',
+    // 'A link to reset your password has been sent by email.' => '',
+    // 'Your profile must have a valid email address.' => '',
+    // 'Unfortunately, we are unable to reset your password. Did you entered a valid username? Do you have an email address in your profile?' => '',
+    // 'TRL - Turkish Lira' => '',
 );
diff --git a/app/Locale/sr_Latn_RS/translations.php b/app/Locale/sr_Latn_RS/translations.php
index bee83a94..2f22774e 100644
--- a/app/Locale/sr_Latn_RS/translations.php
+++ b/app/Locale/sr_Latn_RS/translations.php
@@ -1307,4 +1307,8 @@ return array(
     // 'Credentials' => '',
     // 'New user' => '',
     // 'This username is already taken' => '',
+    // 'A link to reset your password has been sent by email.' => '',
+    // 'Your profile must have a valid email address.' => '',
+    // 'Unfortunately, we are unable to reset your password. Did you entered a valid username? Do you have an email address in your profile?' => '',
+    // 'TRL - Turkish Lira' => '',
 );
diff --git a/app/Locale/sv_SE/translations.php b/app/Locale/sv_SE/translations.php
index ec6f75e1..17e60c03 100644
--- a/app/Locale/sv_SE/translations.php
+++ b/app/Locale/sv_SE/translations.php
@@ -1307,4 +1307,8 @@ return array(
     // 'Credentials' => '',
     // 'New user' => '',
     // 'This username is already taken' => '',
+    // 'A link to reset your password has been sent by email.' => '',
+    // 'Your profile must have a valid email address.' => '',
+    // 'Unfortunately, we are unable to reset your password. Did you entered a valid username? Do you have an email address in your profile?' => '',
+    // 'TRL - Turkish Lira' => '',
 );
diff --git a/app/Locale/th_TH/translations.php b/app/Locale/th_TH/translations.php
index dcd858d0..f8ecd0d2 100644
--- a/app/Locale/th_TH/translations.php
+++ b/app/Locale/th_TH/translations.php
@@ -1307,4 +1307,8 @@ return array(
     // 'Credentials' => '',
     // 'New user' => '',
     // 'This username is already taken' => '',
+    // 'A link to reset your password has been sent by email.' => '',
+    // 'Your profile must have a valid email address.' => '',
+    // 'Unfortunately, we are unable to reset your password. Did you entered a valid username? Do you have an email address in your profile?' => '',
+    // 'TRL - Turkish Lira' => '',
 );
diff --git a/app/Locale/tr_TR/translations.php b/app/Locale/tr_TR/translations.php
index 85a667a6..7c8a7453 100644
--- a/app/Locale/tr_TR/translations.php
+++ b/app/Locale/tr_TR/translations.php
@@ -1307,4 +1307,8 @@ return array(
     // 'Credentials' => '',
     // 'New user' => '',
     // 'This username is already taken' => '',
+    // 'A link to reset your password has been sent by email.' => '',
+    // 'Your profile must have a valid email address.' => '',
+    // 'Unfortunately, we are unable to reset your password. Did you entered a valid username? Do you have an email address in your profile?' => '',
+    // 'TRL - Turkish Lira' => '',
 );
diff --git a/app/Locale/zh_CN/translations.php b/app/Locale/zh_CN/translations.php
index 0f91e29f..76c51a62 100644
--- a/app/Locale/zh_CN/translations.php
+++ b/app/Locale/zh_CN/translations.php
@@ -1307,4 +1307,8 @@ return array(
     // 'Credentials' => '',
     // 'New user' => '',
     // 'This username is already taken' => '',
+    // 'A link to reset your password has been sent by email.' => '',
+    // 'Your profile must have a valid email address.' => '',
+    // 'Unfortunately, we are unable to reset your password. Did you entered a valid username? Do you have an email address in your profile?' => '',
+    // 'TRL - Turkish Lira' => '',
 );
diff --git a/app/Template/password_reset/create.php b/app/Template/password_reset/create.php
index f43d95fc..862a02ba 100644
--- a/app/Template/password_reset/create.php
+++ b/app/Template/password_reset/create.php
@@ -5,6 +5,7 @@
 
         <?= $this->form->label(t('Username'), 'username') ?>
         <?= $this->form->text('username', $values, $errors, array('autofocus', 'required')) ?>
+        <p class="form-help"><?= t('Your profile must have a valid email address.') ?></p>
 
         <?= $this->form->label(t('Enter the text below'), 'captcha') ?>
         <img src="<?= $this->url->href('CaptchaController', 'image') ?>" alt="Captcha">
-- 
cgit v1.2.3