Skip to content

Commit

Permalink
How to use fkash messages instead redirect to additional pages
Browse files Browse the repository at this point in the history
  • Loading branch information
bscheshirwork committed May 31, 2018
1 parent be00cae commit 3ca16f1
Showing 1 changed file with 41 additions and 1 deletion.
42 changes: 41 additions & 1 deletion docs/faq.md
Expand Up @@ -88,4 +88,44 @@ $this->params['breadcrumbs'][] = $this->title;
</p>
</div>
</div>
```
```

## How to use flash messages inside login form directly for registration and recovery actions

You can listen controller's events using `controllerMap` module's property:

```php
'modules' => [
'user' => [
'class' => 'dektrium\user\Module',
'controllerMap' => [
'recovery' => [
'class' => \dektrium\user\controllers\RecoveryController::class,
'on ' . \dektrium\user\controllers\RecoveryController::EVENT_AFTER_REQUEST => function (\dektrium\user\events\FormEvent $event) {
\Yii::$app->controller->redirect(['/user/login']);
\Yii::$app->end();
},
'on ' . \dektrium\user\controllers\RecoveryController::EVENT_AFTER_RESET => function (\dektrium\user\events\ResetPasswordEvent $event) {
if ($event->token->user ?? false) {
\Yii::$app->user->login($event->token->user);
}
\Yii::$app->controller->redirect(\Yii::$app->getUser()->getReturnUrl());
\Yii::$app->end();
},
],
'registration' => [
'class' => \dektrium\user\controllers\RegistrationController::class,
'on ' . \dektrium\user\controllers\RegistrationController::EVENT_AFTER_REGISTER => function (\dektrium\user\events\FormEvent $event) {
\Yii::$app->controller->redirect(['/user/login']);
\Yii::$app->end();
},
'on ' . \dektrium\user\controllers\RegistrationController::EVENT_AFTER_RESEND => function (\dektrium\user\events\FormEvent $event) {
\Yii::$app->controller->redirect(['/user/login']);
\Yii::$app->end();
},
],
],
],
],
```

0 comments on commit 3ca16f1

Please sign in to comment.