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

Commit dae668f

Browse files
committed
Merge pull request #161 from appirio-tech/register-username-errors
Update content and fix username error messages in login and register
2 parents f39a309 + 804bcd7 commit dae668f

File tree

7 files changed

+48
-80
lines changed

7 files changed

+48
-80
lines changed

app/account/login/login.controller.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
function LoginController($log, $state, $stateParams, TcAuthService, AuthTokenService, UserService, NotificationService, Helpers) {
99
var vm = this;
10+
vm.$stateParams = $stateParams;
1011
vm.passwordReset = false;
1112
vm.usernameExists = true;
1213

@@ -57,7 +58,11 @@
5758
}
5859

5960
vm.login = function() {
61+
vm.usernameExists = true;
62+
vm.wrongPassword = false;
63+
6064
if (Helpers.isEmail(vm.username)) {
65+
vm.emailOrUsername = 'email';
6166
// ensure email exists
6267
UserService.validateUserEmail(vm.username).then(function(data) {
6368
if (data.valid) {
@@ -74,10 +79,11 @@
7479
_doLogin(vm.username, vm.password);
7580
});
7681
} else {
82+
vm.emailOrUsername = 'username';
7783
// username - make sure it exists
7884
UserService.validateUserHandle(vm.username).then(function(data) {
7985
if (data.valid) {
80-
// email doesn't exist
86+
// username doesn't exist
8187
vm.usernameExists = false;
8288
} else {
8389
vm.usernameExists = true;
@@ -100,8 +106,6 @@
100106
callbackUrl = $state.href('login', params, {absolute: true});
101107
TcAuthService.socialLogin(backend, callbackUrl);
102108
};
103-
104-
vm.$stateParams = $stateParams;
105109
}
106110

107111
})();

app/account/login/login.jade

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,32 @@
11
.login-container
22
h1 Login
33

4-
form(name="loginForm", role="form", ng-submit="loginForm.$valid && vm.login()", novalidate)
4+
form(name="vm.loginForm", role="form", ng-submit="vm.loginForm.$valid && vm.login()", novalidate)
55
.form-errors
6+
p.form-error(ng-hide="vm.usernameExists") We couldn't find a member with that {{vm.emailOrUsername || "username"}}. Please check that you entered it correctly.
67

7-
p.form-error(ng-hide="vm.usernameExists") This user does not exist.
8-
9-
p.form-error(ng-show="vm.wrongPassword") That password doesn't match the one we have on file. Please try again.
8+
p.form-error(ng-show="vm.wrongPassword") That password is incorrect. Please check that you entered the right one.
109

1110
p.form-error(ng-show="vm.socialLoginError === 401") User with that profile is not registered.
1211

13-
div(ng-show="loginForm.$submitted")
14-
p.form-error(ng-show="loginForm.username.$error.required") Please enter your username or email.
15-
1612
div.validation-bar(ng-class="{'error-bar': !vm.usernameExists}")
17-
input(ng-model="vm.username", ng-blur="vm.usernameExists = true", name="username", placeholder="Username or Email", type="text", required)
13+
input(ng-model="vm.username", name="username", placeholder="Username or Email", type="text", required)
1814

1915
input(ng-model="vm.password", name="password", placeholder="Password", type="password", required)
2016

21-
button(type="submit", ng-disabled="loginForm.$invalid", ng-class="{'enabled-button': loginForm.$valid}") Login
17+
button(type="submit", ng-disabled="vm.loginForm.$invalid", ng-class="{'enabled-button': vm.loginForm.$valid}") Log In
2218

2319
section.social
24-
p log in with another account
20+
p Log in with another account
2521

2622
.social-icons
2723
i.fa.fa-github-square(ng-click="vm.socialLogin('github')")
2824
i.fa.fa-facebook-square(ng-click="vm.socialLogin('facebook')")
2925
i.fa.fa-google-plus-square(ng-click="vm.socialLogin('google-oauth2')")
3026
i.fa.fa-twitter-square(ng-click="vm.socialLogin('twitter')")
3127

32-
a.forgot-password(ui-sref="resetPassword") Forgot Password?
28+
a.forgot-password(ui-sref="resetPassword") Forgot your password?
3329

34-
p.redirect Don't have an account?
35-
a(ui-sref="register(vm.$stateParams)") Join Now.
30+
p.redirect Not a member yet?
31+
a(ui-sref="register(vm.$stateParams)") Join now.
3632

app/account/register/register.jade

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -36,28 +36,26 @@
3636
.tips.username-tips(ng-show="vm.usernameTips")
3737
h3 Username Tips:
3838

39-
p This will be public to other members
39+
p Your username will be public
4040

41-
p Between 2 and 15 characters
41+
p Please choose one that is between 2 and 15 characters
4242

43-
p Can contain numbers and letters
44-
45-
p You can always change it later
43+
p It can contain letters, numbers, and these characters: -_.{}[]
4644

4745
.form-errors
48-
p.form-error(ng-show="vm.registerForm.username.$error.usernameIsFree") This username already exists.
46+
p.form-error(ng-show="vm.registerForm.username.$dirty && vm.registerForm.username.$error.usernameIsFree", ng-bind="vm.usernameErrorMessage")
4947

50-
p.form-error(ng-show="vm.registerForm.username.$error.minlength || vm.registerForm.username.$error.maxlength") Username must be between 2 and 15 characters.
48+
p.form-error(ng-show="vm.registerForm.username.$dirty && (vm.registerForm.username.$error.minlength || vm.registerForm.username.$error.maxlength)") That username is not the correct length or format.
5149

5250
.validation-bar(ng-class="{ 'error-bar': (vm.registerForm.email.$dirty && vm.registerForm.email.$invalid), 'success-bar': (vm.registerForm.email.$valid) }")
5351
input(right-placeholder, focused-placeholder="Email", ng-model="vm.email", ng-model-options="{ debounce: {'default': 500} }", ng-focus="vm.emailTips = true", ng-blur="vm.emailTips = false", name="email", placeholder="Enter Your Email", type="email", valid-email, email-is-available, required)
5452

5553
.tips.email-tips(ng-show="vm.emailTips")
5654
h3 Email Tips:
5755

58-
p This will be private and not shared with anyone.
56+
p Your email address will be private and not shared with anyone.
5957

60-
p We will occasionally send you emails related to your account or interests.
58+
p We'll occasionally send you emails related to your activities or interests.
6159

6260
.form-errors
6361
p.form-error(ng-show="vm.registerForm.email.$dirty && (vm.registerForm.email.$error.emailIsAvailable || vm.registerForm.email.$error.validEmail)", ng-bind="vm.emailErrorMessage")
@@ -70,26 +68,28 @@
7068
.tips.password-tips(ng-show="vm.passwordFocus")
7169
h3 Password Tips:
7270

73-
p(ng-class="{ 'has-length-between-range': (vm.registerForm.password.$dirty && !vm.registerForm.password.$error.minlength && !vm.registerForm.password.$error.maxlength && !vm.registerForm.password.$error.required) }") Must be between 8 and 64 characters
71+
p Your password must have:
72+
73+
p(ng-class="{ 'has-length-between-range': (vm.registerForm.password.$dirty && !vm.registerForm.password.$error.minlength && !vm.registerForm.password.$error.maxlength && !vm.registerForm.password.$error.required) }") At least 8 characters
7474

7575
p(ng-class="{ 'has-letter': (vm.registerForm.password.$dirty && !vm.registerForm.password.$error.hasLetter) }") At least one letter
7676

7777
p(ng-class="{ 'has-symbol-or-number': (vm.registerForm.password.$dirty && !vm.registerForm.password.$error.hasSymbolOrNumber) }") At least one number or symbol
7878

79-
button(type="submit", ng-disabled="vm.registerForm.$invalid", ng-class="{'enabled-button': vm.registerForm.$valid}") Join
79+
button(type="submit", ng-disabled="vm.registerForm.$invalid", ng-class="{'enabled-button': vm.registerForm.$valid}") Join Now
8080

8181
section.terms
82-
p By clicking "JOIN" I agree to Topcoder's
82+
p By clicking "JOIN NOW" you agree to Topcoder's
8383

8484
p #[a(href="http://www.topcoder.com/community/how-it-works/terms/", target="_blank") Terms of Service] and #[a(href="http://www.topcoder.com/community/how-it-works/privacy-policy/", target="_blank") Privacy Policy]
8585

8686
section.social
87-
p Register using another account.
87+
p Use an existing account to register.
8888

8989
.social-icons
9090
i.fa.fa-github-square(ng-click="vm.socialRegister('github')")
9191
i.fa.fa-facebook-square(ng-click="vm.socialRegister('facebook')")
9292
i.fa.fa-google-plus-square(ng-click="vm.socialRegister('google-oauth2')")
9393

94-
p.redirect Already have an account?
95-
a(ui-sref="login(vm.$stateParams)") Login.
94+
p.redirect Already a member?
95+
a(ui-sref="login(vm.$stateParams)") Log in.

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

Lines changed: 0 additions & 46 deletions
This file was deleted.

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

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,23 @@
6565
if (res.valid) {
6666
return defer.resolve();
6767
} else {
68+
switch (res.reasonCode) {
69+
case 'INVALID_LENGTH':
70+
scope.vm.usernameErrorMessage = 'That username is not the correct length or format.';
71+
break;
72+
case 'INVALID_FORMAT':
73+
scope.vm.usernameErrorMessage = 'That username is not the correct length or format.';
74+
break;
75+
case 'INVALID_HANDLE':
76+
scope.vm.usernameErrorMessage = 'That username is not allowed.';
77+
break;
78+
case 'ALREADY_TAKEN':
79+
scope.vm.usernameErrorMessage = 'That username is already taken.'
80+
break;
81+
default:
82+
scope.vm.usernameErrorMessage = 'That username is not the correct length or format.';
83+
}
84+
6885
return defer.reject(res.reasonCode);
6986
}
7087
}).catch(function(err) {

app/index.jade

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,6 @@ html
128128
script(src="directives/account/toggle-password/toggle-password.directive.js")
129129
script(src="directives/account/toggle-password-with-tips/toggle-password-with-tips.directive.js")
130130
script(src="directives/account/validate-email.directive.js")
131-
script(src="directives/account/validate-login.directive.js")
132131
script(src="directives/account/validate-register.directive.js")
133132
script(src="directives/badges/badge-tooltip.directive.js")
134133
script(src="directives/challenge-tiles/challenge-tile.directive.js")

assets/css/topcoder.scss

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,6 @@ a {
121121
}
122122

123123
.form-notice {
124-
margin-top: 5px;
125-
margin-bottom: 5px;
126124
font-size: 13px;
127125
color: #58595B;
128126
}

0 commit comments

Comments
 (0)