Created
May 6, 2015 11:09
-
-
Save basz/e9d116bb41bbe089382d to your computer and use it in GitHub Desktop.
UserId Provider
This file contains hidden or 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
| <?php | |
| namespace Authentication\ZFOAuth2UserIdProvider\Provider\UserId; | |
| use Zend\Authentication\AuthenticationServiceInterface; | |
| use Zend\Stdlib\RequestInterface; | |
| use ZF\OAuth2\Provider\UserId\UserIdProviderInterface; | |
| class Authentication implements UserIdProviderInterface | |
| { | |
| /** | |
| * @var AuthenticationServiceInterface | |
| */ | |
| private $authenticationService; | |
| public function __construct(AuthenticationServiceInterface $authenticationService) { | |
| $this->authenticationService = $authenticationService; | |
| } | |
| /** | |
| * Use the composed request to fetch the identity from the query string | |
| * argument "user_id". | |
| * | |
| * @param RequestInterface $requst | |
| * @return mixed | |
| */ | |
| public function __invoke(RequestInterface $request) | |
| { | |
| if ($this->authenticationService->hasIdentity()) { | |
| return $this->authenticationService->getIdentity()->getUsername(); | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment