-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement SSO Identity Profile Completion (#131)
* implement sso identity profile completion, resolves #121 * update docs * fix unavilable twig helper call * improve oauth parameter bag
- Loading branch information
Showing
44 changed files
with
978 additions
and
134 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
# SSO Identity Listeners | ||
If you need to hook into core decisions, you may want to use som identity state listener: | ||
|
||
## OAUTH_IDENTITY_STATUS_DELETION | ||
Use this event to change the deletion status of a SSO Identity. | ||
This event triggers, if you have enabled the [identity clean-up task](./31_Listener.md). | ||
|
||
```php | ||
<?php | ||
|
||
namespace AppBundle\EventListener; | ||
|
||
use MembersBundle\MembersEvents; | ||
use MembersBundle\Event\OAuth\OAuthIdentityEvent; | ||
use Symfony\Component\EventDispatcher\EventSubscriberInterface; | ||
|
||
class IdentityStatusDeletionEvent implements EventSubscriberInterface | ||
{ | ||
public static function getSubscribedEvents() | ||
{ | ||
return [ | ||
MembersEvents::OAUTH_IDENTITY_STATUS_DELETION => 'onDispatch' | ||
]; | ||
} | ||
|
||
public function onDispatch(OAuthIdentityEvent $event) | ||
{ | ||
$user = $event->getIdentity(); | ||
|
||
// this is just an example | ||
if (!empty($user->getLastLogin())) { | ||
// this will prevent the user deletion | ||
$event->setIdentityDispatchStatus(false); | ||
} | ||
} | ||
} | ||
``` | ||
|
||
## OAUTH_IDENTITY_STATUS_PROFILE_COMPLETION | ||
Use this event to change the status definition if a sso only user is able to call the completion profile route. | ||
By default, an instantly logged in user can complete his profile afterwards in his profile (`/en/members/profile/`, **if no password** has been set. | ||
If you want to change that, use the `OAUTH_IDENTITY_STATUS_PROFILE_COMPLETION` event: | ||
|
||
```php | ||
<?php | ||
|
||
namespace AppBundle\EventListener; | ||
|
||
use MembersBundle\MembersEvents; | ||
use MembersBundle\Event\OAuth\OAuthIdentityEvent; | ||
use Symfony\Component\EventDispatcher\EventSubscriberInterface; | ||
|
||
class IdentityStatusProfileCompletionEvent implements EventSubscriberInterface | ||
{ | ||
public static function getSubscribedEvents() | ||
{ | ||
return [ | ||
MembersEvents::OAUTH_IDENTITY_STATUS_PROFILE_COMPLETION => 'onDispatch' | ||
]; | ||
} | ||
|
||
public function onDispatch(OAuthIdentityEvent $event) | ||
{ | ||
$user = $event->getIdentity(); | ||
|
||
// this is just an example | ||
if (!empty($user->getUsername())) { | ||
// this will prevent the user deletion | ||
$event->setIdentityDispatchStatus(false); | ||
} | ||
} | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.