Skip to content

Commit

Permalink
Fixed problem retrieving user information as it is not yet available …
Browse files Browse the repository at this point in the history
…right after we request login.
  • Loading branch information
Imanol Martin committed Aug 11, 2015
1 parent b86a011 commit 9aa145d
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions src/social/cocoon-gpg/runtime.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,16 +145,16 @@ cr.plugins_.ATPGooglePlayGames = function(runtime) {
Acts.prototype.GPGRequestLogin = function() {
if (!this.GPGInterface) return;
if (this.GPGInterface.isLoggedIn()) {
var user_information = this.GPGInterface.getLoggedInUser();
user_id = user_information.userID;
user_name = user_information.userName;
self.runtime.trigger(cr.plugins_.ATPGooglePlayGames.prototype.cnds.onGPGLoginSuccess, self);

} else {
this.GPGInterface.login(function(loggedIn, error) {
if (loggedIn) {
self.runtime.trigger(cr.plugins_.ATPGooglePlayGames.prototype.cnds.onGPGLoginSuccess, self);

var user_information = this.GPGInterface.getLoggedInUser();

user_id = user_information.userID;
user_name = user_information.userName;
// Cannot call getLoggedInUser here because the information is not yet available.

} else {
console.log(JSON.stringify(error));
Expand Down Expand Up @@ -294,6 +294,11 @@ cr.plugins_.ATPGooglePlayGames = function(runtime) {

if (!this.GPGInterface) return;
if (!this.GPGInterface.isLoggedIn()) return;

var user_information = this.GPGInterface.getLoggedInUser();
user_id = user_information.userID;
user_name = user_information.userName;

this.GPGInterface.requestUserImage(function(imageURL, error){
if (error) {
try {
Expand Down Expand Up @@ -322,10 +327,14 @@ cr.plugins_.ATPGooglePlayGames = function(runtime) {
};

Exps.prototype.UserID = function(ret) {
var user_information = this.GPGInterface.getLoggedInUser();
user_id = user_information.userID;
ret.set_string(user_id);
};

Exps.prototype.UserName = function(ret) {
var user_information = this.GPGInterface.getLoggedInUser();
user_name = user_information.userName;
ret.set_string(user_name);
};

Expand Down

0 comments on commit 9aa145d

Please sign in to comment.