From c8faec9f5fdf850020006156874135f732fb8740 Mon Sep 17 00:00:00 2001 From: Anthony Date: Sat, 7 May 2016 11:28:31 -0700 Subject: [PATCH] fix logout bug --- desktop-app/js/tinder-desktop.api.js | 36 ++++++++++++++-------------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/desktop-app/js/tinder-desktop.api.js b/desktop-app/js/tinder-desktop.api.js index 781101a..cb0753b 100644 --- a/desktop-app/js/tinder-desktop.api.js +++ b/desktop-app/js/tinder-desktop.api.js @@ -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); } @@ -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. + // 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); }; @@ -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; } @@ -294,7 +294,7 @@ }); }); }; - + apiObj.updatePassport = function(lat, lon){ return $q(function (resolve, reject) { client.updatePassport(lat, lon, function(err, res, data) { @@ -307,7 +307,7 @@ }); }); } - + apiObj.resetPassport = function(){ return $q(function (resolve, reject) { client.resetPassport(function(err, res, data) {