Update User object of VK
This commit is contained in:
12
src/User.php
Normal file
12
src/User.php
Normal 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;
|
||||||
|
}
|
||||||
@@ -142,26 +142,11 @@ class Vkontakte extends AbstractProvider
|
|||||||
protected function createResourceOwner(array $response, AccessToken $token)
|
protected function createResourceOwner(array $response, AccessToken $token)
|
||||||
{
|
{
|
||||||
$response = $response->response[0];
|
$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();
|
return new User($response, $token->uid);
|
||||||
|
|
||||||
$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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function userUid($response, AccessToken $token)
|
public function userUid($response, AccessToken $token)
|
||||||
|
|||||||
Reference in New Issue
Block a user