From 692358adb66f6ba94e7907572d465d62588a23cf Mon Sep 17 00:00:00 2001 From: Antonio Ramirez Date: Tue, 13 Jun 2017 00:01:30 +0200 Subject: [PATCH] fixes + add events documentation --- docs/events/form-events.md | 4 +- docs/events/reset-password-events.md | 6 ++- docs/events/social-network-auth-events.md | 48 +++++++++++++++++++ docs/events/social-network-connect-events.md | 47 ++++++++++++++++++ docs/events/user-events.md | 6 +-- .../SocialNetworkAuthenticateService.php | 4 +- 6 files changed, 107 insertions(+), 8 deletions(-) diff --git a/docs/events/form-events.md b/docs/events/form-events.md index 5c108b1..b711ec1 100644 --- a/docs/events/form-events.md +++ b/docs/events/form-events.md @@ -43,8 +43,8 @@ Here is an example of setting an event for the `RecoveryController`: 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 diff --git a/docs/events/social-network-connect-events.md b/docs/events/social-network-connect-events.md index e69de29..3b4d63c 100644 --- a/docs/events/social-network-connect-events.md +++ b/docs/events/social-network-connect-events.md @@ -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 +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 diff --git a/docs/events/user-events.md b/docs/events/user-events.md index b0c9220..8fdefb5 100644 --- a/docs/events/user-events.md +++ b/docs/events/user-events.md @@ -68,9 +68,9 @@ Here is an example of setting an event for the `AdminController` and the `User` client]); + + $event = Yii::createObject(SocialNetworkAuthEvent::class, [$account, $this->client]); $this->controller->trigger(SocialNetworkAuthEvent::EVENT_BEFORE_AUTHENTICATE, $event); + if ($account->user instanceof User) { if ($account->user->getIsBlocked()) { Yii::$app->session->setFlash('danger', Yii::t('usuario', 'Your account has been blocked.'));