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

Commit 6041fae

Browse files
author
Nick Litwin
committed
Update syntax
1 parent e3307f6 commit 6041fae

8 files changed

+166
-163
lines changed

app/account/account.module.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1+
import angular from 'angular'
2+
13
(function() {
2-
'use strict';
4+
'use strict'
35

46
var dependencies = [
57
'ui.router',
@@ -8,13 +10,13 @@
810
'angucomplete-alt',
911
'ngBusy',
1012
'blocks.logger'
11-
];
13+
]
1214

1315
angular.module('tc.account', dependencies)
1416
.config(['$provide',function ($provide) {
1517
$provide.decorator('$log', ['$delegate', 'LogEnhancer', function ($delegate, LogEnhancer) {
16-
LogEnhancer.enhanceLogger($delegate);
17-
return $delegate;
18-
}]);
18+
LogEnhancer.enhanceLogger($delegate)
19+
return $delegate
20+
}])
1921
}])
20-
})();
22+
})()
Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,21 @@
1+
import angular from 'angular'
2+
13
(function() {
2-
'use strict';
4+
'use strict'
35

4-
angular.module('tc.account').controller('LogoutController', LogoutController);
6+
angular.module('tc.account').controller('LogoutController', LogoutController)
57

6-
LogoutController.$inject = ['$log', 'TcAuthService', '$window', 'CONSTANTS'];
8+
LogoutController.$inject = ['$log', 'TcAuthService', '$window', 'CONSTANTS']
79

810
function LogoutController($log, TcAuthService, $window, CONSTANTS) {
9-
$log = $log.getInstance('LogoutController');
11+
$log = $log.getInstance('LogoutController')
1012

1113
TcAuthService.logout()
1214
.then(function() {
13-
$log.debug("successfully logged out.");
15+
$log.debug('successfully logged out.')
1416
// redirect to home
15-
$window.location.href = CONSTANTS.MAIN_URL;
16-
});
17+
$window.location.href = CONSTANTS.MAIN_URL
18+
})
1719

1820
}
19-
})();
21+
})()
Lines changed: 61 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,52 @@
1+
import angular from 'angular'
2+
import _ from 'lodash'
3+
14
(function() {
2-
'use strict';
5+
'use strict'
36

4-
angular.module('tc.account').controller('RegisterController', RegisterController);
7+
angular.module('tc.account').controller('RegisterController', RegisterController)
58

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

811
function RegisterController($log, CONSTANTS, $state, $stateParams, TcAuthService, UserService, ISO3166, Helpers) {
9-
$log = $log.getInstance("RegisterController");
10-
$log.debug("-init");
11-
var vm = this;
12-
vm.registering = false;
12+
$log = $log.getInstance('RegisterController')
13+
$log.debug('-init')
14+
var vm = this
15+
vm.registering = false
1316
// prepares utm params, if available
1417
var utm = {
1518
source : $stateParams && $stateParams.utm_source ? $stateParams.utm_source : '',
1619
medium : $stateParams && $stateParams.utm_medium ? $stateParams.utm_medium : '',
1720
campaign : $stateParams && $stateParams.utm_campaign ? $stateParams.utm_campaign : ''
18-
};
21+
}
1922

2023

2124
// Set default for toggle password directive
22-
vm.defaultPlaceholder = 'Create Password';
23-
vm.busyMessage = CONSTANTS.BUSY_PROGRESS_MESSAGE;
25+
vm.defaultPlaceholder = 'Create Password'
26+
vm.busyMessage = CONSTANTS.BUSY_PROGRESS_MESSAGE
2427

2528
// FIXME - This needs to be setup with https
2629
// lookup users country
2730
// Helpers.getCountyObjFromIP()
2831
// .then(function(obj) {
29-
// vm.countryObj = obj;
30-
// });
32+
// vm.countryObj = obj
33+
// })
3134

32-
vm.countries = ISO3166.getAllCountryObjects();
35+
vm.countries = ISO3166.getAllCountryObjects()
3336

3437
vm.updateCountry = function (angucompleteCountryObj) {
35-
var countryCode = _.get(angucompleteCountryObj, 'originalObject.code', undefined);
38+
var countryCode = _.get(angucompleteCountryObj, 'originalObject.code', undefined)
3639

37-
var isValidCountry = _.isUndefined(countryCode) ? false : true;
38-
vm.registerForm.country.$setValidity('required', isValidCountry);
39-
vm.isValidCountry = isValidCountry;
40+
var isValidCountry = _.isUndefined(countryCode) ? false : true
41+
vm.registerForm.country.$setValidity('required', isValidCountry)
42+
vm.isValidCountry = isValidCountry
4043
if (isValidCountry) {
41-
vm.country = angucompleteCountryObj.originalObject;
44+
vm.country = angucompleteCountryObj.originalObject
4245
}
43-
};
46+
}
4447

4548
vm.register = function() {
46-
vm.registering = true;
49+
vm.registering = true
4750
var userInfo = {
4851
handle: vm.username,
4952
firstName: vm.firstname,
@@ -57,14 +60,14 @@
5760
utmSource: utm.source,
5861
utmMedium: utm.medium,
5962
utmCampaign: utm.campaign
60-
};
63+
}
6164

6265
if (!vm.isSocialRegistration) {
63-
userInfo.credential = { password: vm.password };
66+
userInfo.credential = { password: vm.password }
6467
} else {
6568
userInfo.profile = {
6669
userId: vm.socialUserId,
67-
name: vm.firstname + " " + vm.lastname,
70+
name: vm.firstname + ' ' + vm.lastname,
6871
email: vm.socialProfile.email,
6972
emailVerified: vm.socialProfile.email_verified,
7073
providerType: vm.socialProvider,
@@ -82,65 +85,64 @@
8285
}
8386
}
8487

85-
$log.debug('attempting to register user');
88+
$log.debug('attempting to register user')
8689
TcAuthService.register(body)
8790
.then(function(data) {
88-
vm.registering = false;
89-
$log.debug('registered successfully');
91+
vm.registering = false
92+
$log.debug('registered successfully')
9093

9194
// In the future, go to dashboard
92-
$state.go('registeredSuccessfully');
95+
$state.go('registeredSuccessfully')
9396
})
9497
.catch(function(err) {
95-
vm.registering = false;
96-
$log.error('Error in registering new user: ', err);
97-
});
98-
};
98+
vm.registering = false
99+
$log.error('Error in registering new user: ', err)
100+
})
101+
}
99102

100103
vm.socialRegister = function(provider) {
101104
TcAuthService.socialRegistration(provider, null)
102105
.then(function(resp) {
103106
if (resp.status === 'SUCCESS') {
104-
var socialData = resp.data;
105-
vm.socialUserId = socialData.socialUserId;
106-
vm.username = socialData.username;
107+
var socialData = resp.data
108+
vm.socialUserId = socialData.socialUserId
109+
vm.username = socialData.username
107110
if (socialData.username) {
108-
vm.registerForm.username.$setDirty();
111+
vm.registerForm.username.$setDirty()
109112
}
110-
vm.firstname = socialData.firstname;
113+
vm.firstname = socialData.firstname
111114
if (socialData.firstname) {
112-
vm.registerForm.firstname.$setDirty();
115+
vm.registerForm.firstname.$setDirty()
113116
}
114-
vm.lastname = socialData.lastname;
117+
vm.lastname = socialData.lastname
115118
if (socialData.lastname) {
116-
vm.registerForm.lastname.$setDirty();
119+
vm.registerForm.lastname.$setDirty()
117120
}
118121
if (socialData.email) {
119-
vm.registerForm.email.$setDirty();
122+
vm.registerForm.email.$setDirty()
120123
}
121-
vm.email = socialData.email;
122-
vm.socialProfile = socialData.socialProfile;
123-
vm.socialProvider = socialData.socialProvider;
124-
vm.socialContext= {'accessToken': socialData.accessToken};
125-
vm.isSocialRegistration = true;
124+
vm.email = socialData.email
125+
vm.socialProfile = socialData.socialProfile
126+
vm.socialProvider = socialData.socialProvider
127+
vm.socialContext= {'accessToken': socialData.accessToken}
128+
vm.isSocialRegistration = true
126129
} else {
127-
vm.isSocialRegistration = false;
130+
vm.isSocialRegistration = false
128131
}
129132
})
130133
.catch(function(result) {
131-
switch (result.status) {
132-
case "SOCIAL_PROFILE_ALREADY_EXISTS":
133-
vm.errMsg = "An account with that profile already exists. Please login to access your account.";
134-
break;
135-
default:
136-
vm.errMsg = "Whoops! Something went wrong. Please try again later.";
137-
break;
138-
}
139-
vm.isSocialRegistration = false;
140-
});
141-
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+
})
142144
}
143145

144-
vm.$stateParams = $stateParams;
146+
vm.$stateParams = $stateParams
145147
}
146-
})();
148+
})()

app/account/register/register.spec.js

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,36 @@
11
/* jshint -W117, -W030 */
22
describe('Register Controller', function() {
3-
var controller;
3+
var controller
44

55
beforeEach(function() {
6-
bard.appModule('topcoder');
7-
bard.inject('$controller', '$rootScope', '$q');
8-
9-
10-
});
6+
bard.appModule('topcoder')
7+
bard.inject('$controller', '$rootScope', '$q')
8+
})
119

1210
var state = {
1311
href: function() {
14-
return 'http://topcoder-dev.com/register/';
12+
return 'http://topcoder-dev.com/register/'
1513
}
1614
}
1715

1816
beforeEach(function() {
1917
var helperService = {
2018
getCountyObjFromIP: function() {
21-
return $q.when({name: "United States", alpha2: "US", alpha3: "USA", code: "840"});
19+
return $q.when({name: "United States", alpha2: "US", alpha3: "USA", code: "840"})
2220
}
23-
};
21+
}
2422

2523
controller = $controller('RegisterController', {
2624
$state: state,
2725
Helpers: helperService
28-
});
26+
})
2927

30-
$rootScope.$apply();
31-
});
28+
$rootScope.$apply()
29+
})
3230

33-
bard.verifyNoOutstandingHttpRequests();
31+
bard.verifyNoOutstandingHttpRequests()
3432

3533
it('should be created successfully', function() {
36-
expect(controller).to.be.defined;
37-
});
38-
39-
});
34+
expect(controller).to.be.defined
35+
})
36+
})

0 commit comments

Comments
 (0)