diff --git a/app/profile/profile.controller.js b/app/profile/profile.controller.js index 1ead6b9cc..0a558a47e 100644 --- a/app/profile/profile.controller.js +++ b/app/profile/profile.controller.js @@ -28,7 +28,6 @@ import moment from 'moment' 'COPILOT': 'copilot' } - logger.debug() vm.status = { 'badges': CONSTANTS.STATE_LOADING, 'stats': CONSTANTS.STATE_LOADING, diff --git a/app/services/jwtInterceptor.service.js b/app/services/jwtInterceptor.service.js index 3a9aa43a0..111840e23 100644 --- a/app/services/jwtInterceptor.service.js +++ b/app/services/jwtInterceptor.service.js @@ -27,8 +27,6 @@ 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 next = $state.href('dashboard', {}, {absolute: true}) - $window.location = CONSTANTS.ACCOUNTS_APP_URL + '?retUrl=' + encodeURIComponent(next) return null }) @@ -82,10 +80,8 @@ import { isTokenExpired, getFreshToken } from 'tc-accounts' // logger.debug('idToken: ' + idToken) if (!TcAuthService.isAuthenticated() || idToken == null) { - // logger.debug('redirecting to accounts app') - var next = $state.href('dashboard', {}, {absolute: true}) - $window.location = CONSTANTS.ACCOUNTS_APP_URL + '?retUrl=' + encodeURIComponent(next) - return + logger.debug(String.supplant('Skipping authToken for "{url}, UnAuthenticated user"', config)) + return null } // Note only v3tokens expire diff --git a/app/services/jwtInterceptor.service.spec.js b/app/services/jwtInterceptor.service.spec.js index e5a43d22a..8715e1896 100644 --- a/app/services/jwtInterceptor.service.spec.js +++ b/app/services/jwtInterceptor.service.spec.js @@ -78,28 +78,24 @@ describe('JWT Interceptor Service', function() { expect(TcAuthService.isAuthenticated).to.be.have.been.calledOnce }) - it('should redirect to login page for other endpoints', function() { + it('should return null as token for other endpoints', function() { var config = { method: 'get', url: apiUrl + '/v3/members/test' } - service.getToken(config) - expect($window.location).not.null - expect($window.location).to.have.string(CONSTANTS.ACCOUNTS_APP_URL) + var token = service.getToken(config) expect(TcAuthService.isAuthenticated).to.be.have.been.calledOnce - expect(fakeState.href).to.be.calledWith('dashboard') + expect(token).to.be.null }) - it('should redirect to login page for other endpoints', function() { + it('should return null as token for other endpoints', function() { var config = { method: 'get', url: apiUrl + '/v3.0.0-BETA/members/test' } - service.getToken(config) - expect($window.location).not.null - expect($window.location).to.have.string(CONSTANTS.ACCOUNTS_APP_URL) + var token = service.getToken(config) expect(TcAuthService.isAuthenticated).to.be.have.been.calledOnce - expect(fakeState.href).to.be.calledWith('dashboard') + expect(token).to.be.null }) afterEach(function() { diff --git a/app/skill-picker/skill-picker.controller.js b/app/skill-picker/skill-picker.controller.js index 53f2c28fc..75b0668d0 100644 --- a/app/skill-picker/skill-picker.controller.js +++ b/app/skill-picker/skill-picker.controller.js @@ -6,9 +6,9 @@ import _ from 'lodash' angular.module('tc.skill-picker').controller('SkillPickerController', SkillPickerController) - SkillPickerController.$inject = ['$scope', 'CONSTANTS', 'ProfileService', '$state', 'userProfile', 'featuredSkills', 'logger', 'toaster', 'MemberCertService', '$q', 'UserPreferencesService'] + SkillPickerController.$inject = ['$scope', 'CONSTANTS', 'ProfileService', '$state', 'userProfile', 'featuredSkills', 'logger', 'toaster', 'MemberCertService', '$q'] - function SkillPickerController($scope, CONSTANTS, ProfileService, $state, userProfile, featuredSkills, logger, toaster, MemberCertService, $q, UserPreferencesService) { + function SkillPickerController($scope, CONSTANTS, ProfileService, $state, userProfile, featuredSkills, logger, toaster, MemberCertService, $q) { var vm = this vm.ASSET_PREFIX = CONSTANTS.ASSET_PREFIX vm.IOS_PROGRAM_ID = CONSTANTS.SWIFT_PROGRAM_ID @@ -32,7 +32,6 @@ import _ from 'lodash' * Activates the controller. */ function activate() { - addToMailingList() initCommunities() checkCommunityStatus() } @@ -138,25 +137,6 @@ import _ from 'lodash' } } - function addToMailingList() { - return UserPreferencesService.getEmailPreferences(userProfile).then(function(subscription) { - logger.debug(subscription) - if (!subscription) { - return UserPreferencesService.saveEmailPreferences(userProfile).then(function(resp) { - logger.debug(resp) - }).catch(function(err) { - // no error to user - //TODO some error alert to community admin - logger.debug('error in adding user to member list') - }) - } - }).catch(function(err) { - // no error to user - //TODO some error alert to community admin - logger.debug('error in adding user to member list') - }) - } - /** * Persists the user's altered information. */ diff --git a/app/skill-picker/skill-picker.spec.js b/app/skill-picker/skill-picker.spec.js index 0d361f49f..096dbeb35 100644 --- a/app/skill-picker/skill-picker.spec.js +++ b/app/skill-picker/skill-picker.spec.js @@ -138,39 +138,6 @@ describe('Skill Picker Controller', function() { CONSTANTS.SWIFT_PROGRAM_ID = origSwiftProgId }) - it('should call mailchimp service to add subscription', function() { - expect(vm).to.exist - // getEmailPreferences should always be called - expect(userPrefSvc.getEmailPreferences).to.be.calledOnce - // saveEmailPreferences should be called once if not subscribed - // getEmailPreferences service mock returns null for mockProfile.userId - expect(userPrefSvc.saveEmailPreferences).to.be.calledOnce - }) - - it('should not call mailchimp service to add subscription', function() { - // reset getEmailPreferences, saveEmailPreferences spy's called count - userPrefSvc.getEmailPreferences.reset() - userPrefSvc.saveEmailPreferences.reset() - var scope = $rootScope.$new() - - var profile = angular.copy(mockProfile) - // update userId to return valid object in service mock - profile.userId = 12345 - vm = $controller('SkillPickerController', { - $scope: scope, - userProfile: profile, - featuredSkills: [], - $state: state - }) - $rootScope.$digest() - expect(vm).to.exist - // getEmailPreferences should always be called - expect(userPrefSvc.getEmailPreferences).to.be.calledOnce - // saveEmailPreferences should not be called if already subscribed - // getEmailPreferences service mock returns valid object for userId 12345 - expect(userPrefSvc.saveEmailPreferences).not.to.be.called - }) - it('should add skill ', function() { vm.toggleSkill(409) expect(vm.mySkills).to.exist.have.length(1) diff --git a/webpack.config.js b/webpack.config.js index 9160c5b6f..ff285298e 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -37,6 +37,18 @@ const config = require('appirio-tech-webpack-config')({ } }) +if (process.env.ENV === 'DEV') { + config.devServer = config.devServer ? config.devServer : {} + config.devServer.proxy = [ + { + path: /\/members\/.*/, + bypass: function(req, res, proxyOptions) { + return '/index.html' + } + } + ] +} + if (CI) config.output.publicPath = process.env.ASSET_PREFIX if (accountsAppURL) {