Permalink
Browse files

"real_name" field may be undefined (when no permission or when user d…

…idn't fill his profile)
  • Loading branch information...
1 parent 9951980 commit 5bce397261fd40d53e2ae6a3bff52c6ff3e2c443 @abalandin abalandin committed Oct 24, 2012
Showing with 6 additions and 2 deletions.
  1. +6 −2 lib/passport-yandex/strategy.js
@@ -93,8 +93,12 @@ Strategy.prototype.userProfile = function(accessToken, done) {
profile.id = json.id;
profile.username = json.display_name;
profile.displayName = json.display_name;
- profile.name = { familyName: json.real_name.split(' ')[0],
- givenName: json.real_name.split(' ')[1] };
+ if (json.real_name) {
+ var tokens = json.real_name.split(' ', 2);
+ profile.name = {familyName: tokens[0], givenName: tokens[1]};
+ } else {
+ profile.name = {};
+ }
profile.gender = json.sex;
profile.emails = [{ value: json.default_email }];

0 comments on commit 5bce397

Please sign in to comment.