fixes + add events documentation
This commit is contained in:
@ -43,8 +43,8 @@ Here is an example of setting an event for the `RecoveryController`:
|
||||
<?php
|
||||
// events.php file
|
||||
|
||||
use Da\Controller\RecoveryController;
|
||||
use Da\Event\FormEvent;
|
||||
use Da\User\Controller\RecoveryController;
|
||||
use Da\User\Event\FormEvent;
|
||||
use yii\base\Event;
|
||||
|
||||
Event::on(RecoveryController::class, FormEvent::EVENT_BEFORE_REQUEST, function (FormEvent $event) {
|
||||
|
||||
@ -25,8 +25,8 @@ Check the following code as an example:
|
||||
<?php
|
||||
// events.php file
|
||||
|
||||
use Da\Controller\RecoveryController;
|
||||
use Da\Event\ResetPasswordEvent;
|
||||
use Da\User\Controller\RecoveryController;
|
||||
use Da\User\Event\ResetPasswordEvent;
|
||||
use yii\base\Event;
|
||||
|
||||
Event::on(
|
||||
@ -52,3 +52,5 @@ Event::on(
|
||||
});
|
||||
|
||||
```
|
||||
|
||||
© [2amigos](http://www.2amigos.us/) 2013-2017
|
||||
|
||||
@ -0,0 +1,48 @@
|
||||
Social Network Auth Events
|
||||
==========================
|
||||
|
||||
The following is the list of the social network authentication events and where they happen:
|
||||
|
||||
|
||||
On Controllers
|
||||
--------------
|
||||
|
||||
- **SecurityController**
|
||||
- **SocialNetworkAuthEvent::EVENT_BEFORE_CONNECT**: Occurs before a user's social network has been connected
|
||||
- **SocialNetworkAuthEvent::EVENT_AFTER_CONNECT**: Occurs after a user's social network has been connected
|
||||
- **SocialNetworkAuthEvent::EVENT_BEFORE_AUTHENTICATE**: Occurs before a user is authenticated via social network
|
||||
- **SocialNetworkAuthEvent::EVENT_AFTER_AUTHENTICATE**: Occurs after a a user is authenticated via social network
|
||||
|
||||
|
||||
How to Work With Social Network Auth Events
|
||||
-------------------------------------------
|
||||
|
||||
This event when triggered will contain a `Da\User\Model\SocialNetworkAccount` model instance and also the client used
|
||||
to authenticate throughout a social network. For example:
|
||||
|
||||
```php
|
||||
<?php
|
||||
// events.php file
|
||||
|
||||
use Da\User\Controller\SecurityController;
|
||||
use Da\User\Event\SocialNetworkAuthEvent;
|
||||
use yii\base\Event;
|
||||
|
||||
Event::on(
|
||||
SecurityController::class,
|
||||
SocialNetworkAuthEvent::EVENT_BEFORE_CONNECT,
|
||||
function (SocialNetworkAuthEvent $event) {
|
||||
|
||||
$client = $event->getClient(); // $client is one of the Da\User\AuthClient\ clients
|
||||
$account = $event->getAccount(); // $account is a Da\User\Model\SocialNetworkAccount
|
||||
|
||||
// ... your logic here
|
||||
});
|
||||
|
||||
```
|
||||
|
||||
> For further information about how to authenticate via social networks and the available clients, please visit the
|
||||
> [guide](../helpful-guides/social-network-authentication.md)
|
||||
|
||||
|
||||
© [2amigos](http://www.2amigos.us/) 2013-2017
|
||||
|
||||
@ -0,0 +1,47 @@
|
||||
Social Network Connect Events
|
||||
=============================
|
||||
|
||||
The following is the list of the social network connection events and where they happen:
|
||||
|
||||
|
||||
On Controllers
|
||||
--------------
|
||||
|
||||
- **RegistrationController**
|
||||
- **SocialNetworkConnectEvent::EVENT_BEFORE_CONNECT**: Occurs before a user's social network has been connected
|
||||
- **SocialNetworkConnectEvent::EVENT_AFTER_CONNECT**: Occurs after a user's social network has been connected
|
||||
|
||||
|
||||
- **SettingsController**
|
||||
- **SocialNetworkConnectEvent::EVENT_BEFORE_DISCONNECT**: Occurs before a user is disconnecting a social network
|
||||
- **SocialNetworkConnectEvent::EVENT_AFTER_DISCONNECT**: Occurs after a a user is disconnecting a social network
|
||||
|
||||
|
||||
How to Work With Social Network Connect Events
|
||||
----------------------------------------------
|
||||
|
||||
This event when triggered will contain a `Da\User\Model\User` model instance and also a
|
||||
`Da\User\Model\SocialNetworkAccount` instance. For example:
|
||||
|
||||
```php
|
||||
<?php
|
||||
// events.php file
|
||||
|
||||
use Da\User\Controller\RegistrationController;
|
||||
use Da\User\Event\SocialNetworkConnectEvent;
|
||||
use yii\base\Event;
|
||||
|
||||
Event::on(
|
||||
RegistrationController::class,
|
||||
SocialNetworkConnectEvent::EVENT_BEFORE_CONNECT,
|
||||
function (SocialNetworkConnectEvent $event) {
|
||||
|
||||
$user = $event->getUser(); // $token is a Da\User\Model\User instance
|
||||
$account = $event->getAccount(); // $account is a Da\User\Model\SocialNetworkAccount
|
||||
|
||||
// ... your logic here
|
||||
});
|
||||
|
||||
```
|
||||
|
||||
© [2amigos](http://www.2amigos.us/) 2013-2017
|
||||
|
||||
@ -68,9 +68,9 @@ Here is an example of setting an event for the `AdminController` and the `User`
|
||||
<?php
|
||||
// events.php file
|
||||
|
||||
use Da\Controller\AdminController;
|
||||
use Da\Event\UserEvent;
|
||||
use Da\Model\User;
|
||||
use Da\User\Controller\AdminController;
|
||||
use Da\User\Event\UserEvent;
|
||||
use Da\User\Model\User;
|
||||
use yii\base\Event;
|
||||
|
||||
// This will happen at the controller's level
|
||||
|
||||
Reference in New Issue
Block a user