Amélioration de l'expérience utilisateur
This commit is contained in:
@@ -52,9 +52,12 @@ class DefaultController extends \Piko\Controller
|
||||
|
||||
if (!empty($post)) {
|
||||
|
||||
$user = new User($this->db);
|
||||
$module = $this->module;
|
||||
assert ($module instanceof \app\modules\user\Module);
|
||||
|
||||
$user = new User($this->db);
|
||||
$user->scenario = User::SCENARIO_REGISTER;
|
||||
$user->passwordMinLength = $module->passwordMinLength;
|
||||
|
||||
$user->bind($post);
|
||||
|
||||
@@ -89,8 +92,12 @@ class DefaultController extends \Piko\Controller
|
||||
|
||||
if (!empty($post)) {
|
||||
|
||||
$module = $this->module;
|
||||
assert ($module instanceof \app\modules\user\Module);
|
||||
|
||||
$user = new User($this->db);
|
||||
$user->scenario = 'register';
|
||||
$user->passwordMinLength = $module->passwordMinLength;
|
||||
$user->bind($post);
|
||||
$user->isValid();
|
||||
$errors = $user->getErrors();
|
||||
@@ -156,13 +163,17 @@ class DefaultController extends \Piko\Controller
|
||||
}
|
||||
|
||||
if ($user) {
|
||||
// $user->sendResetPassword();
|
||||
$app = $this->module->getApplication();
|
||||
$router = $app->getComponent('Piko\Router');
|
||||
$mailer = $app->getComponent('Nette\Mail\SmtpMailer');
|
||||
$user->sendResetPassword($router, $mailer);
|
||||
$message['type'] = 'success';
|
||||
$message['content'] = __(
|
||||
'user',
|
||||
'A link has been sent to you by email ({email}). It will allow you to recreate your password.',
|
||||
['email' => $user->email]
|
||||
);
|
||||
$reminder = '';
|
||||
} else {
|
||||
$message['type'] = 'danger';
|
||||
$message['content'] = __('user', 'Account not found.');
|
||||
@@ -186,7 +197,7 @@ class DefaultController extends \Piko\Controller
|
||||
$user = User::findByAuthKey($token);
|
||||
|
||||
if (!$user) {
|
||||
throw new HttpException('Not found', 404);
|
||||
throw new HttpException('User not found', 404);
|
||||
}
|
||||
|
||||
$message = false;
|
||||
|
||||
Reference in New Issue
Block a user