• Notice: New feature requests and suggestions won't be considered for Chevereto development at this time. Learn more.

Fixed VK Auth don't work

Rodolfo

Chevereto Guru
Staff member
Joined
Oct 7, 2008
Messages
15,766
Likes
3,997
Points
237
Location
Chevereto HQ
Website
rodolfoberrios.com
#2
I never got the dev update or anything about it. Do you know about?
 

Wink

Founder license
Joined
Mar 4, 2012
Messages
23
Likes
7
Points
53
#3
Oh, I think I fixed it. Just adding API version to queries, like this

Code:
    public function api($method, array $query = array())
    {
        /* Generate query string from array */
        foreach ($query as $param => $value) {
            if (is_array($value)) {
                // implode values of each nested array with comma
                $query[$param] = implode(',', $value);
            }
        }
        $query['v'] = self::API_VERSION;
        $query['access_token'] = isset($this->accessToken['access_token'])
            ? $this->accessToken['access_token']
            : '';
        $url = 'https://api.vk.com/method/' . $method . '?' . http_build_query($query);
        $result = json_decode($this->curl($url), true);

        if (isset($result['response'])) {
            return $result['response'];
        }

        return $result;
    }
 

Wink

Founder license
Joined
Mar 4, 2012
Messages
23
Likes
7
Points
53
#4
Please check this lines in route.connect.php (line 267)

Code:
$connect_user = [
    'id'        => $get_user['uid'],
    'username'    => G\sanitize_string(G\unaccent_string($get_user['first_name'] . $get_user['last_name']), true, true),
    'name'        => trim($get_user['first_name'] . ' ' . $get_user['last_name']),
    'avatar'    => $get_user['photo_200'],
    'url'        => 'http://vk.com/' . $get_user['domain'],
    'website'    => $get_user['site']
];
It's a part of VK auth. We get $get_user from API, but $get_user['uid'] is empty and auth will be incorrect. All correct fields from API response are here: https://vk.com/dev/users.get and here: https://vk.com/dev/objects/user
I change it to fix this bug:

Code:
'id' => isset($get_user['id'])? $get_user['id'] : $get_user['uid'],
 
Last edited:

Rodolfo

Chevereto Guru
Staff member
Joined
Oct 7, 2008
Messages
15,766
Likes
3,997
Points
237
Location
Chevereto HQ
Website
rodolfoberrios.com
#5
Thanks, your patch fixes this issue. I will add it to the next revision.