Skip to content

Commit

Permalink
fix logout bug
Browse files Browse the repository at this point in the history
  • Loading branch information
mayeaux committed May 7, 2016
1 parent 24bed56 commit c8faec9
Showing 1 changed file with 18 additions and 18 deletions.
36 changes: 18 additions & 18 deletions desktop-app/js/tinder-desktop.api.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
(function() {
var tinder = require('tinder');
var client = new tinder.TinderClient();
var remote = require('remote');
var remote = require('remote');

// if a token returned from tinder is in localstorage, set that token and skip auth
if (localStorage.tinderToken) { client.setAuthToken(localStorage.tinderToken); }
Expand All @@ -13,20 +13,20 @@
var handleError = function(err, callbackFn) {
console.log('ERROR!!!!');
console.log(err);

// Tinder API token is not valid.
if (err.status === 401 && localStorage.getItem('fbTokenExpiresAt') != null) {
if(Date.parse(localStorage.fbTokenExpiresAt) > new Date()) {
// Facebook token is still good. Get a new Tinder token.
apiObj.login(localStorage.fbUserId, localStorage.fbToken);
} else {
// Facebook token expired. Get a new Facebook token.
$location.path('/login');
}
} else {
// Something's gone horribly wrong. Log the user out.
apiObj.logout();
}
//
// // Tinder API token is not valid.

This comment has been minimized.

Copy link
@hashier

hashier Dec 14, 2016

I ran into auth problems. So I enabled those lines again and it started working again

This comment has been minimized.

Copy link
@mayeaux

mayeaux Dec 14, 2016

Author Member

What was happening? @hashier

This comment has been minimized.

Copy link
@hashier

hashier Dec 14, 2016

I saw a lot of:

stderr: [42152:1214/102825:INFO:CONSOLE(14)] "ERROR!!!!", source: file:///private/tmp/tinder-desktop/desktop-app/js/tinder-desktop.api.js (14)

stderr: [42152:1214/102825:INFO:CONSOLE(15)] "Error: Unauthorized", source: file:///private/tmp/tinder-desktop/desktop-app/js/tinder-desktop.api.js (15)

stderr: [42152:1214/102835:INFO:CONSOLE(14)] "ERROR!!!!", source: file:///private/tmp/tinder-desktop/desktop-app/js/tinder-desktop.api.js (14)

stderr: [42152:1214/102835:INFO:CONSOLE(15)] "Error: Unauthorized", source: file:///private/tmp/tinder-desktop/desktop-app/js/tinder-desktop.api.js (15)

so I allowed the reauth, and it worked:

What was not working: I just saw a spinner "loading" and nothing happened.

// if (err.status === 401 && localStorage.getItem('fbTokenExpiresAt') != null) {
// if(Date.parse(localStorage.fbTokenExpiresAt) > new Date()) {
// // Facebook token is still good. Get a new Tinder token.
// apiObj.login(localStorage.fbUserId, localStorage.fbToken);
// } else {
// // Facebook token expired. Get a new Facebook token.
// $location.path('/login');
// }
// } else {
// // Something's gone horribly wrong. Log the user out.
// apiObj.logout();
// }
(callbackFn || angular.noop)(err);
};

Expand Down Expand Up @@ -141,7 +141,7 @@
apiObj.getAccount = function() {
return $q(function (resolve, reject) {
client.getAccount(function(err, res, data) {
if (!!err) {
if (!!err) {
handleError(err, reject);
return;
}
Expand Down Expand Up @@ -294,7 +294,7 @@
});
});
};

apiObj.updatePassport = function(lat, lon){
return $q(function (resolve, reject) {
client.updatePassport(lat, lon, function(err, res, data) {
Expand All @@ -307,7 +307,7 @@
});
});
}

apiObj.resetPassport = function(){
return $q(function (resolve, reject) {
client.resetPassport(function(err, res, data) {
Expand Down

0 comments on commit c8faec9

Please sign in to comment.