From a23c393f01f6238c4c484764f8237f2249f1f710 Mon Sep 17 00:00:00 2001 From: vikasrohit Date: Mon, 11 Jul 2016 14:53:48 +0530 Subject: [PATCH 1/3] AS#153276200846788, Redirect loop for some users on production -- Fixed. Checking for v2 token and cookies seem to be the issue. --- app/services/tcAuth.service.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/services/tcAuth.service.js b/app/services/tcAuth.service.js index 9aee1a3dc..306c951ef 100644 --- a/app/services/tcAuth.service.js +++ b/app/services/tcAuth.service.js @@ -25,7 +25,7 @@ import { getCurrentUser, logout as doLogout } from './userv3.service.js' } function isAuthenticated() { - return !!getCurrentUser() && !!AuthTokenService.getV2Token() && !!AuthTokenService.getTCSSOToken() + return !!getCurrentUser() } } From f711f755c1c06a640cc6f9f91442f18cc2304162 Mon Sep 17 00:00:00 2001 From: vikasrohit Date: Mon, 11 Jul 2016 14:57:33 +0530 Subject: [PATCH 2/3] AS#153276200846788, Redirect loop for some users on production -- Fixed incorrect redirection. It should redirect to dashboard after accounts app validation instead of MAIN_URL. --- app/services/jwtInterceptor.service.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/services/jwtInterceptor.service.js b/app/services/jwtInterceptor.service.js index ac734f750..3a9aa43a0 100644 --- a/app/services/jwtInterceptor.service.js +++ b/app/services/jwtInterceptor.service.js @@ -27,8 +27,8 @@ import { isTokenExpired, getFreshToken } from 'tc-accounts' .catch(function(err) { // Server will not or cannot refresh token logger.debug('Unable to refresh V3 token, redirecting to login') - var retUrl = CONSTANTS.MAIN_URL + '/?next=' + config.url - $window.location = CONSTANTS.ACCOUNTS_APP_URL + '?retUrl=' + encodeURIComponent(retUrl) + var next = $state.href('dashboard', {}, {absolute: true}) + $window.location = CONSTANTS.ACCOUNTS_APP_URL + '?retUrl=' + encodeURIComponent(next) return null }) @@ -83,8 +83,8 @@ import { isTokenExpired, getFreshToken } from 'tc-accounts' // logger.debug('idToken: ' + idToken) if (!TcAuthService.isAuthenticated() || idToken == null) { // logger.debug('redirecting to accounts app') - var retUrl = CONSTANTS.MAIN_URL + '/?next=' + config.url - $window.location = CONSTANTS.ACCOUNTS_APP_URL + '?retUrl=' + encodeURIComponent(retUrl) + var next = $state.href('dashboard', {}, {absolute: true}) + $window.location = CONSTANTS.ACCOUNTS_APP_URL + '?retUrl=' + encodeURIComponent(next) return } From 5b062e89176a7e6109785e0ba76be8e99663a750 Mon Sep 17 00:00:00 2001 From: vikasrohit Date: Mon, 11 Jul 2016 15:37:34 +0530 Subject: [PATCH 3/3] AS#153276200846788, Redirect loop for some users on production -- Fixed unit tests --- app/services/jwtInterceptor.service.spec.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/app/services/jwtInterceptor.service.spec.js b/app/services/jwtInterceptor.service.spec.js index 7dac6c7d3..e5a43d22a 100644 --- a/app/services/jwtInterceptor.service.spec.js +++ b/app/services/jwtInterceptor.service.spec.js @@ -27,6 +27,9 @@ describe('JWT Interceptor Service', function() { fakeState = { go: sinon.spy(function(param) { return + }), + href: sinon.spy(function(stateName, toParams, params) { + return 'https://topcoder.com/' + stateName }) }, fakeWindow = { @@ -84,6 +87,7 @@ describe('JWT Interceptor Service', function() { expect($window.location).not.null expect($window.location).to.have.string(CONSTANTS.ACCOUNTS_APP_URL) expect(TcAuthService.isAuthenticated).to.be.have.been.calledOnce + expect(fakeState.href).to.be.calledWith('dashboard') }) it('should redirect to login page for other endpoints', function() { @@ -95,6 +99,7 @@ describe('JWT Interceptor Service', function() { expect($window.location).not.null expect($window.location).to.have.string(CONSTANTS.ACCOUNTS_APP_URL) expect(TcAuthService.isAuthenticated).to.be.have.been.calledOnce + expect(fakeState.href).to.be.calledWith('dashboard') }) afterEach(function() {