Skip to content
This repository was archived by the owner on Mar 4, 2025. It is now read-only.

Commit 6f0fcb4

Browse files
committed
Merge pull request #762 from appirio-tech/qa-integration
Qa integration
2 parents 388b9d4 + c276ddd commit 6f0fcb4

File tree

73 files changed

+911
-481
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

73 files changed

+911
-481
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ Install dependencies by running the following in the root of the project:
1313
- `npm i`
1414
- **Note:** You must use npm 3. Type `npm -v` to ensure you have a 3.x version.
1515

16-
In order to test a logged in user, you must make an entry in your `/etc/hosts` file, pointing `local.topcoder-dev.com` to `localhost`. For example, open your `/etc/hosts` file with something like `vim /etc/hosts` and add `127.0.0.1 local.topcoder-dev.com`. After you run `gulp serve`, which launches a new window or tab, change `http://localhost:3000/login/` to `http://local.topcoder-dev.com:3000/login/`. You will then be able to login and pick up information from the cookies with `.topcoder-dev.com` as the domain.
16+
In order to test a logged in user, you must make an entry in your `/etc/hosts` file, pointing `local.topcoder-dev.com` to `localhost`. For example, open your `/etc/hosts` file with something like `vim /etc/hosts` and add `127.0.0.1 local.topcoder-dev.com`.
1717

1818
## NPM Commands
1919
- To run locally: `npm start` and head to `local.topcoder-dev.com:3000/login`

app/account/account.module.js

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,4 @@ import angular from 'angular'
1212
]
1313

1414
angular.module('tc.account', dependencies)
15-
.config(['$provide',function ($provide) {
16-
$provide.decorator('$log', ['$delegate', 'LogEnhancer', function ($delegate, LogEnhancer) {
17-
LogEnhancer.enhanceLogger($delegate)
18-
return $delegate
19-
}])
20-
}])
2115
})()

app/account/account.routes.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@ import angular from 'angular'
1515
data: {
1616
authRequired: false
1717
},
18-
onEnter: ['$state', '$stateParams', 'TcAuthService', '$log', function($state, $stateParams, TcAuthService, $log) {
18+
onEnter: ['$state', '$stateParams', 'TcAuthService', 'logger', function($state, $stateParams, TcAuthService, logger) {
1919
if (TcAuthService.isAuthenticated()) {
2020
// redirect to next if exists else dashboard
2121
if ($stateParams.next) {
22-
$log.debug('Redirecting: ' + $stateParams.next)
22+
logger.debug('Redirecting: ' + $stateParams.next)
2323
window.location.href = decodeURIComponent($stateParams.next)
2424
} else {
2525
$state.go('dashboard')

app/account/login/login.controller.js

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,10 @@ import angular from 'angular'
55

66
angular.module('tc.account').controller('LoginController', LoginController)
77

8-
LoginController.$inject = ['$log', '$state', '$stateParams', '$location', '$scope', 'TcAuthService', 'UserService', 'Helpers', 'CONSTANTS']
8+
LoginController.$inject = ['logger', '$state', '$stateParams', '$location', '$scope', 'TcAuthService', 'UserService', 'Helpers', 'CONSTANTS']
99

10-
function LoginController($log, $state, $stateParams, $location, $scope, TcAuthService, UserService, Helpers, CONSTANTS) {
10+
function LoginController(logger, $state, $stateParams, $location, $scope, TcAuthService, UserService, Helpers, CONSTANTS) {
1111
var vm = this
12-
$log = $log.getInstance('LoginController')
1312
vm.$stateParams = $stateParams
1413
vm.passwordReset = false
1514
vm.loginErrors = {
@@ -76,27 +75,28 @@ import angular from 'angular'
7675
}
7776

7877
function _doLogin(usernameOrEmail, password) {
79-
return TcAuthService.login(usernameOrEmail, password).then(function(data) {
80-
// success
81-
$log.debug('logged in')
78+
return TcAuthService.login(usernameOrEmail, password)
79+
.then(function(data) {
80+
// setup login event for analytics tracking
81+
Helpers.setupLoginEventMetrics(usernameOrEmail)
82+
return Helpers.redirectPostLogin($stateParams.next)
8283

83-
// setup login event for analytics tracking
84-
Helpers.setupLoginEventMetrics(usernameOrEmail)
85-
return Helpers.redirectPostLogin($stateParams.next)
86-
87-
}).catch(function(resp) {
88-
$log.warn(resp)
89-
switch (resp.status) {
90-
case 'ACCOUNT_INACTIVE':
91-
$state.go('registeredSuccessfully')
92-
// user should already be redirected
93-
break
94-
case 'UNKNOWN_ERROR':
95-
default:
96-
vm.loginErrors.WRONG_PASSWORD = true
97-
vm.password = ''
98-
}
99-
})
84+
})
85+
.catch(function(err) {
86+
logger.warning(err)
87+
88+
switch (err.status) {
89+
case 'ACCOUNT_INACTIVE':
90+
$state.go('registeredSuccessfully')
91+
// user should already be redirected
92+
break
93+
case 'UNKNOWN_ERROR':
94+
default:
95+
vm.loginErrors.WRONG_PASSWORD = true
96+
vm.password = ''
97+
logger.error('Error logging in: ', err)
98+
}
99+
})
100100
}
101101

102102
function socialLogin(platform) {
@@ -111,19 +111,19 @@ import angular from 'angular'
111111

112112
TcAuthService.socialLogin(platform, callbackUrl)
113113
.then(function() {
114-
$log.debug('logged in')
114+
logger.debug('logged in')
115115
return Helpers.redirectPostLogin($stateParams.next)
116116
})
117-
.catch(function(resp) {
117+
.catch(function(err) {
118118
/*eslint no-fallthrough:0*/
119-
switch (resp.status) {
119+
switch (err.status) {
120120
case 'ACCOUNT_INACTIVE':
121121
window.location.href = 'https://www.' + CONSTANTS.domain + '/account-inactive/'
122122
case 'USER_NOT_REGISTERED':
123123
default:
124124
vm.socialLoginError = 401
125125
vm.loginErrors.SOCIAL_LOGIN_ERROR = true
126-
break
126+
logger.error('Error logging in with social account', err)
127127
}
128128
})
129129
}

app/account/logout/logout.controller.js

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,16 @@ import angular from 'angular'
55

66
angular.module('tc.account').controller('LogoutController', LogoutController)
77

8-
LogoutController.$inject = ['$log', 'TcAuthService', '$window', 'CONSTANTS']
8+
LogoutController.$inject = ['logger', 'TcAuthService', '$window', 'CONSTANTS']
99

10-
function LogoutController($log, TcAuthService, $window, CONSTANTS) {
11-
$log = $log.getInstance('LogoutController')
10+
function LogoutController(logger, TcAuthService, $window, CONSTANTS) {
1211

1312
TcAuthService.logout()
1413
.then(function() {
15-
$log.debug('successfully logged out.')
16-
// redirect to home
14+
logger.debug('Successfully logged out.')
15+
16+
// Redirect to home
1717
$window.location.href = CONSTANTS.MAIN_URL
1818
})
19-
2019
}
2120
})()

app/account/register/register.controller.js

Lines changed: 21 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,9 @@ import _ from 'lodash'
66

77
angular.module('tc.account').controller('RegisterController', RegisterController)
88

9-
RegisterController.$inject = ['$log', 'CONSTANTS', '$state', '$stateParams', 'TcAuthService', 'UserService', 'ISO3166', 'Helpers']
9+
RegisterController.$inject = ['logger', 'CONSTANTS', '$state', '$stateParams', 'TcAuthService', 'UserService', 'ISO3166', 'Helpers']
1010

11-
function RegisterController($log, CONSTANTS, $state, $stateParams, TcAuthService, UserService, ISO3166, Helpers) {
12-
$log = $log.getInstance('RegisterController')
13-
$log.debug('-init')
11+
function RegisterController(logger, CONSTANTS, $state, $stateParams, TcAuthService, UserService, ISO3166, Helpers) {
1412
var vm = this
1513
vm.registering = false
1614
// prepares utm params, if available
@@ -20,18 +18,10 @@ import _ from 'lodash'
2018
campaign : $stateParams && $stateParams.utm_campaign ? $stateParams.utm_campaign : ''
2119
}
2220

23-
2421
// Set default for toggle password directive
2522
vm.defaultPlaceholder = 'Create Password'
2623
vm.busyMessage = CONSTANTS.BUSY_PROGRESS_MESSAGE
2724

28-
// FIXME - This needs to be setup with https
29-
// lookup users country
30-
// Helpers.getCountyObjFromIP()
31-
// .then(function(obj) {
32-
// vm.countryObj = obj
33-
// })
34-
3525
vm.countries = ISO3166.getAllCountryObjects()
3626

3727
vm.updateCountry = function (angucompleteCountryObj) {
@@ -85,18 +75,18 @@ import _ from 'lodash'
8575
}
8676
}
8777

88-
$log.debug('attempting to register user')
8978
TcAuthService.register(body)
9079
.then(function(data) {
9180
vm.registering = false
92-
$log.debug('registered successfully')
81+
logger.debug('Registered successfully')
9382

9483
// In the future, go to dashboard
9584
$state.go('registeredSuccessfully')
9685
})
9786
.catch(function(err) {
9887
vm.registering = false
99-
$log.error('Error in registering new user: ', err)
88+
89+
logger.error('Error in registering new user', err)
10090
})
10191
}
10292

@@ -130,17 +120,22 @@ import _ from 'lodash'
130120
vm.isSocialRegistration = false
131121
}
132122
})
133-
.catch(function(result) {
134-
switch (result.status) {
135-
case 'SOCIAL_PROFILE_ALREADY_EXISTS':
136-
vm.errMsg = 'An account with that profile already exists. Please login to access your account.'
137-
break
138-
default:
139-
vm.errMsg = 'Whoops! Something went wrong. Please try again later.'
140-
break
141-
}
142-
vm.isSocialRegistration = false
143-
})
123+
.catch(function(err) {
124+
switch (err.status) {
125+
case 'SOCIAL_PROFILE_ALREADY_EXISTS':
126+
vm.errMsg = 'An account with that profile already exists. Please login to access your account.'
127+
128+
logger.error('Error registering user with social account', err)
129+
130+
break
131+
132+
default:
133+
vm.errMsg = 'Whoops! Something went wrong. Please try again later.'
134+
135+
logger.error('Error registering user with social account', err)
136+
}
137+
vm.isSocialRegistration = false
138+
})
144139
}
145140

146141
vm.$stateParams = $stateParams

app/blocks/logger/logger.js

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,11 @@ import angular from 'angular'
1212
var service = {
1313
showToasts: false,
1414

15-
error: error,
16-
info: info,
15+
error : error,
16+
info : info,
1717
success: success,
1818
warning: warning,
19+
debug : debug,
1920

2021
// straight to console bypass toastr
2122
log: $log.log
@@ -25,19 +26,33 @@ import angular from 'angular'
2526
/////////////////////
2627

2728
function error(message, data, title) {
28-
$log.error('Error: ' + message, data)
29+
if (data) {
30+
message = `${message} ${JSON.stringify(data)}`
31+
}
32+
33+
$log.error(message)
34+
35+
if (window.NREUM) {
36+
var err = new Error(message)
37+
38+
window.NREUM.noticeError(err)
39+
}
2940
}
3041

3142
function info(message, data, title) {
32-
$log.info('Info: ' + message, data)
43+
$log.info('Info: ' + message, data ? data : '')
3344
}
3445

3546
function success(message, data, title) {
36-
$log.info('Success: ' + message, data)
47+
$log.info('Success: ' + message, data ? data : '')
48+
}
49+
50+
function debug(message, data, title) {
51+
$log.debug('Debug: ' + message, data ? data : '')
3752
}
3853

3954
function warning(message, data, title) {
40-
$log.warn('Warning: ' + message, data)
55+
$log.warn('Warning: ' + message, data ? data : '')
4156
}
4257
}
4358
}())

app/directives/account/validate-register.directive.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,14 +52,14 @@ import angular from 'angular'
5252
}
5353
}
5454

55-
usernameIsFree.$inject = ['UserService', '$log', '$q']
55+
usernameIsFree.$inject = ['UserService', 'logger', '$q']
5656

57-
function usernameIsFree(UserService, $log, $q) {
57+
function usernameIsFree(UserService, logger, $q) {
5858
return {
5959
require: 'ngModel',
6060
link: function(scope, element, attrs, ctrl) {
6161
ctrl.$asyncValidators.usernameIsFree = function(modelValue, viewValue) {
62-
$log.info('Validating username: ' + modelValue)
62+
logger.info('Validating username: ' + modelValue)
6363

6464
var defer = $q.defer()
6565

@@ -97,14 +97,14 @@ import angular from 'angular'
9797
}
9898
}
9999

100-
emailIsAvailable.$inject = ['UserService', '$log', '$q']
100+
emailIsAvailable.$inject = ['UserService', 'logger', '$q']
101101

102-
function emailIsAvailable(UserService, $log, $q) {
102+
function emailIsAvailable(UserService, logger, $q) {
103103
return {
104104
require: 'ngModel',
105105
link: function(scope, element, attrs, ctrl) {
106106
ctrl.$asyncValidators.emailIsAvailable = function(modelValue, viewValue) {
107-
$log.info('Validating email: ' + modelValue)
107+
logger.info('Validating email: ' + modelValue)
108108

109109
var defer = $q.defer()
110110

0 commit comments

Comments
 (0)