Browse files

bugfix

  • Loading branch information...
1 parent 4f7ec39 commit 7718ff694a54fb85973365737fd2cb31b3281328 @svasva committed Jan 29, 2013
Showing with 15 additions and 5 deletions.
  1. +1 −1 smart.json
  2. +14 −4 vk_server.js
View
2 smart.json
@@ -3,7 +3,7 @@
"description": "Login service for VKontakte accounts",
"homepage": "https://github.com/erundook/meteor-accounts-vkontakte",
"author": "Vitaly A. Sorokin",
- "version": "0.1.6",
+ "version": "0.1.7",
"git": "https://github.com/erundook/meteor-accounts-vkontakte.git"
}
View
18 vk_server.js
@@ -4,8 +4,10 @@
var accessToken = getAccessToken(query);
var profile = getUserInfo(accessToken.access_token);
- profile.city = getCity(accessToken.access_token, profile.city);
- profile.country = getCountry(accessToken.access_token, profile.country);
+ if (profile.city)
+ profile.city = getCity(accessToken.access_token, profile.city);
+ if (profile.country)
+ profile.country = getCountry(accessToken.access_token, profile.country);
profile.name = profile.first_name + ' ' + profile.last_name;
return {
serviceData: {
@@ -44,7 +46,11 @@
result.content = JSON.parse(result.content);
if (result.content.error) // if the http response was a json object with an error attribute
throw result.content;
- return result.content.response[0].name;
+ var resp = result.content.response;
+ if (resp && resp[0] && resp[0].name)
+ return resp[0].name;
+ else
+ return 'unknown';
};
var getCountry = function (access_token, cityId) {
@@ -59,7 +65,11 @@
result.content = JSON.parse(result.content);
if (result.content.error) // if the http response was a json object with an error attribute
throw result.content;
- return result.content.response[0].name;
+ var resp = result.content.response;
+ if (resp && resp[0] && resp[0].name)
+ return resp[0].name;
+ else
+ return 'unknown';
};

0 comments on commit 7718ff6

Please sign in to comment.