Skip to content

Commit

Permalink
Add extra fields to credentials
Browse files Browse the repository at this point in the history
  • Loading branch information
Thibaud Fabre committed Feb 13, 2015
1 parent 2c5130b commit 8179227
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 5 deletions.
44 changes: 41 additions & 3 deletions src/Adapter/League/Oauth1/Credentials.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ class Credentials implements OauthCredentials
{

/**
*
* @var TokenCredentials
*/
*
* @var TokenCredentials
*/
private $credentials;

/**
Expand All @@ -34,6 +34,7 @@ public function __construct(TokenCredentials $credentials, User $user)

/**
* (non-PHPdoc)
*
* @see \Aztech\Layers\Oauth\Credentials::getUid()
*/
public function getUid()
Expand All @@ -43,10 +44,47 @@ public function getUid()

/**
* (non-PHPdoc)
*
* @see \Aztech\Layers\Oauth\Credentials::getName()
*/
public function getName()
{
return $this->user->name;
}

/**
* (non-PHPdoc)
* @see \Aztech\Layers\Oauth\Credentials::getLastName()
*/
public function getLastName()
{
return $this->user->lastName;
}

/**
* (non-PHPdoc)
* @see \Aztech\Layers\Oauth\Credentials::getFirstName()
*/
public function getFirstName()
{
return $this->user->firstName;
}

/**
* (non-PHPdoc)
* @see \Aztech\Layers\Oauth\Credentials::getEmail()
*/
public function getEmail()
{
return $this->user->email;
}

/**
* (non-PHPdoc)
* @see \Aztech\Layers\Oauth\Credentials::getAvatar()
*/
public function getAvatar()
{
return $this->user->imageUrl;
}
}
24 changes: 22 additions & 2 deletions src/Adapter/League/Oauth2/Credentials.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
namespace Aztech\Layers\Oauth\Adapter\League\Oauth2;

use Aztech\Layers\Oauth\Credentials as OauthCredentials;
use League\OAuth2\Client\Grant\AuthorizationCode;
use League\OAuth2\Client\Entity\User;
use League\OAuth2\Client\Token\AccessToken;

class Credentials implements OauthCredentials
{
Expand All @@ -26,7 +26,7 @@ class Credentials implements OauthCredentials
* @param TokenCredentials $credentials
* @param User $user
*/
public function __construct(AuthorizationCode $credentials, User $user)
public function __construct(AccessToken $credentials, User $user)
{
$this->credentials = $credentials;
$this->user = $user;
Expand All @@ -49,4 +49,24 @@ public function getName()
{
return $this->user->name;
}

public function getLastName()
{
return $this->user->lastName;
}

public function getFirstName()
{
return $this->user->firstName;
}

public function getEmail()
{
return $this->user->email;
}

public function getAvatar()
{
return $this->user->imageUrl;
}
}
8 changes: 8 additions & 0 deletions src/Credentials.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,13 @@ interface Credentials

public function getUid();

public function getLastName();

public function getFirstName();

public function getName();

public function getEmail();

public function getAvatar();
}

0 comments on commit 8179227

Please sign in to comment.