From dd29b600c412c34bc583433fa0c92880785fc8fc Mon Sep 17 00:00:00 2001 From: matthew kirchhof Date: Fri, 16 Jun 2023 14:33:51 -0400 Subject: [PATCH] fix:Remove unnecessary and deprecated api call, bump api version --- src/Adapters/Auth/vkontakte.js | 59 ++++++++-------------------------- 1 file changed, 13 insertions(+), 46 deletions(-) diff --git a/src/Adapters/Auth/vkontakte.js b/src/Adapters/Auth/vkontakte.js index 46fd1248ae..35c40b6ca1 100644 --- a/src/Adapters/Auth/vkontakte.js +++ b/src/Adapters/Auth/vkontakte.js @@ -7,56 +7,23 @@ var Parse = require('parse/node').Parse; // Returns a promise that fulfills iff this user id is valid. function validateAuthData(authData, params) { - return vkOAuth2Request(params).then(function (response) { - if (response && response.access_token) { - return request( - 'api.vk.com', - 'method/users.get?access_token=' + authData.access_token + '&v=' + params.apiVersion - ).then(function (response) { - if ( - response && - response.response && - response.response.length && - response.response[0].id == authData.id - ) { - return; - } - throw new Parse.Error(Parse.Error.OBJECT_NOT_FOUND, 'Vk auth is invalid for this user.'); - }); - } - throw new Parse.Error(Parse.Error.OBJECT_NOT_FOUND, 'Vk appIds or appSecret is incorrect.'); - }); -} + if (!params.apiVersion) { + params.apiVersion = '5.131'; + } -function vkOAuth2Request(params) { - return new Promise(function (resolve) { + return request( + 'api.vk.com', + 'method/users.get?access_token=' + authData.access_token + '&v=' + params.apiVersion + ).then(function (response) { if ( - !params || - !params.appIds || - !params.appIds.length || - !params.appSecret || - !params.appSecret.length + response && + response.response && + response.response.length && + response.response[0].id == authData.id ) { - throw new Parse.Error( - Parse.Error.OBJECT_NOT_FOUND, - 'Vk auth is not configured. Missing appIds or appSecret.' - ); - } - if (!params.apiVersion) { - params.apiVersion = '5.124'; + return; } - resolve(); - }).then(function () { - return request( - 'oauth.vk.com', - 'access_token?client_id=' + - params.appIds + - '&client_secret=' + - params.appSecret + - '&v=' + - params.apiVersion + - '&grant_type=client_credentials' - ); + throw new Parse.Error(Parse.Error.OBJECT_NOT_FOUND, 'Vk auth is invalid for this user.'); }); }