Skip to content

Instantly share code, notes, and snippets.

@basz
Created May 6, 2015 11:09
Show Gist options
  • Select an option

  • Save basz/e9d116bb41bbe089382d to your computer and use it in GitHub Desktop.

Select an option

Save basz/e9d116bb41bbe089382d to your computer and use it in GitHub Desktop.
UserId Provider
<?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