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

Commit b985fc5

Browse files
author
Nick Litwin
committed
Update to remove
1 parent ee4349b commit b985fc5

File tree

49 files changed

+208
-237
lines changed

Some content is hidden

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

49 files changed

+208
-237
lines changed

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: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ import angular from 'angular'
55

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

8-
LoginController.$inject = ['$log', 'logger', '$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, logger, $state, $stateParams, $location, $scope, TcAuthService, UserService, Helpers, CONSTANTS) {
10+
function LoginController(logger, $state, $stateParams, $location, $scope, TcAuthService, UserService, Helpers, CONSTANTS) {
1111
var vm = this
1212
vm.$stateParams = $stateParams
1313
vm.passwordReset = false
@@ -75,28 +75,28 @@ import angular from 'angular'
7575
}
7676

7777
function _doLogin(usernameOrEmail, password) {
78-
return TcAuthService.login(usernameOrEmail, password).then(function(data) {
79-
// success
80-
$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)
8183

82-
// setup login event for analytics tracking
83-
Helpers.setupLoginEventMetrics(usernameOrEmail)
84-
return Helpers.redirectPostLogin($stateParams.next)
85-
86-
}).catch(function(err) {
87-
$log.warn(err)
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-
})
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,7 +111,7 @@ 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
})
117117
.catch(function(err) {

app/account/logout/logout.controller.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@ 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
})
1919
}

app/account/register/register.controller.js

Lines changed: 3 additions & 14 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', 'logger', 'CONSTANTS', '$state', '$stateParams', 'TcAuthService', 'UserService', 'ISO3166', 'Helpers']
9+
RegisterController.$inject = ['logger', 'CONSTANTS', '$state', '$stateParams', 'TcAuthService', 'UserService', 'ISO3166', 'Helpers']
1010

11-
function RegisterController($log, logger, 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,11 +75,10 @@ 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')

app/blocks/logger/logger.js

Lines changed: 10 additions & 5 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
@@ -39,15 +40,19 @@ import angular from 'angular'
3940
}
4041

4142
function info(message, data, title) {
42-
$log.info('Info: ' + message, data)
43+
$log.info('Info: ' + message, data ? data : '')
4344
}
4445

4546
function success(message, data, title) {
46-
$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 : '')
4752
}
4853

4954
function warning(message, data, title) {
50-
$log.warn('Warning: ' + message, data)
55+
$log.warn('Warning: ' + message, data ? data : '')
5156
}
5257
}
5358
}())

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

app/directives/external-account/external-account.directive.js

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -24,20 +24,21 @@ import _ from 'lodash'
2424
linkedAccounts: '=',
2525
readOnly: '='
2626
},
27-
controller: ['$log', 'logger', '$scope', 'ExternalAccountService', 'toaster',
28-
function($log, logger, $scope, ExternalAccountService, toaster) {
29-
30-
$log = $log.getInstance('ExtAccountDirectiveCtrl')
31-
27+
controller: ['logger', '$scope', 'ExternalAccountService', 'toaster',
28+
function(logger, $scope, ExternalAccountService, toaster) {
3229
var _accountList = _.clone(_supportedAccounts, true)
30+
3331
_.remove(_accountList, function(al) { return al.order < 0})
32+
3433
$scope.$watchCollection('linkedAccounts', function(newValue, oldValue) {
3534
if (newValue) {
3635
angular.forEach(_accountList, function(account) {
3736
var _linkedAccount = _.find(newValue, function(p) {
3837
return p.provider === account.provider
3938
})
39+
4040
var accountStatus = _.get(_linkedAccount, 'data.status', null)
41+
4142
if (!_linkedAccount) {
4243
account.status = 'unlinked'
4344
} else if(accountStatus && accountStatus.toLowerCase() === 'pending') {
@@ -46,9 +47,11 @@ import _ from 'lodash'
4647
account.status = 'linked'
4748
}
4849
})
50+
4951
$scope.accountList = _accountList
52+
5053
} else {
51-
// reset the status for all accounts
54+
// Reset the status for all accounts
5255
angular.forEach(_accountList, function(account) {
5356
delete account.status
5457
})
@@ -59,20 +62,26 @@ import _ from 'lodash'
5962
provider = _.find(_supportedAccounts, function(s) {
6063
return s.provider === provider
6164
})
65+
6266
if (status === 'linked') {
63-
$log.debug(String.supplant('UnLinking to ' + provider.displayName))
67+
logger.debug(String.supplant('UnLinking to ' + provider.displayName))
68+
6469
_unlink(provider)
70+
6571
} else if (status === 'unlinked') {
66-
$log.debug(String.supplant('Linking to ' + provider.displayName))
72+
logger.debug(String.supplant('Linking to ' + provider.displayName))
73+
6774
_link(provider)
6875
}
6976
}
7077

7178
function _link(provider) {
7279
ExternalAccountService.linkExternalAccount(provider.provider, null)
7380
.then(function(resp) {
74-
$log.debug('Social account linked: ' + JSON.stringify(resp))
81+
logger.debug('Social account linked: ' + JSON.stringify(resp))
82+
7583
$scope.linkedAccounts.push(resp.linkedAccount)
84+
7685
toaster.pop('success', 'Success',
7786
String.supplant(
7887
'Your {provider} account has been linked. Data from your linked account will be visible on your profile shortly.',
@@ -82,7 +91,7 @@ import _ from 'lodash'
8291
})
8392
.catch(function(err) {
8493
if (err.status === 'SOCIAL_PROFILE_ALREADY_EXISTS') {
85-
$log.info('Social profile already linked to another account')
94+
logger.info('Social profile already linked to another account')
8695

8796
toaster.pop('error', 'Whoops!',
8897
String.supplant(
@@ -102,10 +111,12 @@ import _ from 'lodash'
102111
function _unlink(provider) {
103112
return ExternalAccountService.unlinkExternalAccount(provider.provider)
104113
.then(function(resp) {
105-
$log.debug('Social account unlinked: ' + JSON.stringify(resp))
114+
logger.debug('Social account unlinked: ' + JSON.stringify(resp))
115+
106116
var toRemove = _.findIndex($scope.linkedAccounts, function(la) {
107117
return la.provider === provider.provider
108118
})
119+
109120
if (toRemove > -1) {
110121
// remove from the linkedAccounts array
111122
$scope.linkedAccounts.splice(toRemove, 1)
@@ -121,7 +132,7 @@ import _ from 'lodash'
121132
var msg = err.msg
122133

123134
if (err.status === 'SOCIAL_PROFILE_NOT_EXIST') {
124-
$log.info('Social profile not linked to account')
135+
logger.info('Social profile not linked to account')
125136

126137
msg = '{provider} account is not linked to your account. If you think this is an error please contact <a href=\"mailTo:[email protected]\">[email protected]</a>.'
127138
} else {

app/directives/external-account/external-link-deletion.controller.js

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,29 +5,28 @@ import _ from 'lodash'
55
angular.module('tcUIComponents')
66
.controller('ExternalLinkDeletionController', ExternalLinkDeletionController)
77

8-
ExternalLinkDeletionController.$inject = ['ExternalWebLinksService', '$q', '$log', 'logger', 'toaster', 'ngDialog', 'userHandle', 'account', 'linkedAccountsData']
8+
ExternalLinkDeletionController.$inject = ['ExternalWebLinksService', '$q', 'logger', 'toaster', 'ngDialog', 'userHandle', 'account', 'linkedAccountsData']
99

10-
function ExternalLinkDeletionController(ExternalWebLinksService, $q, $log, logger, toaster, ngDialog, userHandle, account, linkedAccountsData) {
10+
function ExternalLinkDeletionController(ExternalWebLinksService, $q, logger, toaster, ngDialog, userHandle, account, linkedAccountsData) {
1111
var vm = this
1212
vm.account = account
13-
$log = $log.getInstance('ExternalLinkDeletionController')
1413

1514
vm.deleteAccount = function() {
16-
$log.debug('Deleting Account...')
15+
logger.debug('Deleting Account...')
1716

1817
if (account && account.deletingAccount) {
19-
$log.debug('Another deletion is already in progress.')
18+
logger.debug('Another deletion is already in progress.')
2019
return
2120
}
2221

2322
if (account && account.provider === 'weblink') {
2423
account.deletingAccount = true
25-
$log.debug('Deleting weblink...')
24+
logger.debug('Deleting weblink...')
2625

2726
return ExternalWebLinksService.removeLink(userHandle, account.key)
2827
.then(function(data) {
2928
account.deletingAccount = false
30-
$log.debug('Web link removed: ' + JSON.stringify(data))
29+
logger.debug('Web link removed: ' + JSON.stringify(data))
3130
var toRemove = _.findIndex(linkedAccountsData, function(la) {
3231
return la.provider === 'weblink' && la.key === account.key
3332
})
@@ -40,7 +39,7 @@ import _ from 'lodash'
4039
.catch(function(err) {
4140
var msg = err.msg
4241
if (err.status === 'WEBLINK_NOT_EXIST') {
43-
$log.info('Weblink does not exist')
42+
logger.info('Weblink does not exist')
4443

4544
msg = 'Weblink is not linked to your account. If you think this is an error please contact <a href=\"mailTo:[email protected]\">[email protected]</a>.'
4645
} else {

0 commit comments

Comments
 (0)