Update User object of VK

This commit is contained in:
trogwar
2016-06-29 22:24:53 +03:00
parent b64d43ed62
commit 6652435afc
2 changed files with 17 additions and 20 deletions

12
src/User.php Normal file
View File

@@ -0,0 +1,12 @@
<?php
namespace J4k\OAuth2\Client\Provider;
use League\OAuth2\Client\Provider\GenericResourceOwner;
class User extends GenericResourceOwner
{
public $email;
public $location;
public $description;
}

View File

@@ -142,26 +142,11 @@ class Vkontakte extends AbstractProvider
protected function createResourceOwner(array $response, AccessToken $token)
{
$response = $response->response[0];
$response['email'] = property_exists($token, 'email') ? $token->email : null;
$response['location'] = property_exists($response, 'country') ? $response->country : null;
$response['description'] = property_exists($response, 'status') ? $response->status : null;
$user = new User();
$email = (isset($token->email)) ? $token->email : null;
$location = (isset($response->country)) ? $response->country : null;
$description = (isset($response->status)) ? $response->status : null;
$user->exchangeArray([
'uid' => $response->uid,
'nickname' => $response->nickname,
'name' => $response->screen_name,
'firstname' => $response->first_name,
'lastname' => $response->last_name,
'email' => $email,
'location' => $location,
'description' => $description,
'imageUrl' => $response->photo_200_orig,
]);
return $user;
return new User($response, $token->uid);
}
public function userUid($response, AccessToken $token)