Skip to content

Commit 1ec98a1

Browse files
authored
Merge pull request #1686 from code-corps/1685-fix-signup-form-validatio
Fix sign up form validation
2 parents eca0ef2 + 2edccc3 commit 1ec98a1

File tree

6 files changed

+19
-30
lines changed

6 files changed

+19
-30
lines changed

app/components/signup-email-input.js

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -66,14 +66,12 @@ export default Component.extend({
6666
});
6767
},
6868

69-
actions: {
70-
keyDown() {
71-
once(this, '_check');
72-
if (get(this, 'isNotSameEmail')) {
73-
set(this, 'isChecking', true);
74-
}
69+
validateEmail: function() {
70+
once(this, '_check');
71+
if (get(this, 'isNotSameEmail')) {
72+
set(this, 'isChecking', true);
7573
}
76-
},
74+
}.observes('email'),
7775

7876
_check() {
7977
set(this, 'isChecking', true);

app/components/signup-password-input.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export default Component.extend({
1919
suggestions: alias('strength.feedback.suggestions'),
2020

2121
password: computed('user.password', function() {
22-
return this.get('user.password') || '';
22+
return get(this, 'user.password') || '';
2323
}),
2424

2525
strength: computed('password', function() {
@@ -28,14 +28,14 @@ export default Component.extend({
2828
}),
2929

3030
strengthPercentage: computed('isValid', 'passwordLength', 'strength', function() {
31-
let isValid = this.get('isValid');
31+
let isValid = get(this, 'isValid');
3232
let percentage = 0;
3333

3434
if (isValid) {
35-
let score = this.get('strength.score');
35+
let score = get(this, 'strength.score');
3636
percentage = (score / 4) * 100;
3737
} else {
38-
percentage = this.get('passwordLength');
38+
percentage = get(this, 'passwordLength');
3939
}
4040

4141
return percentage;

app/components/signup-username-input.js

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,13 @@ export default Component.extend({
184184
return get(this, 'cachedUsername') === get(this, 'username');
185185
}),
186186

187+
validateUsername: function() {
188+
once(this, '_check');
189+
if (get(this, 'isNotSameUsername')) {
190+
set(this, 'isChecking', true);
191+
}
192+
}.observes('username'),
193+
187194
/**
188195
Checks if the username is valid and available. Caches the username so that
189196
it doesn't have to request more than once.
@@ -222,22 +229,6 @@ export default Component.extend({
222229
});
223230
},
224231

225-
actions: {
226-
227-
/**
228-
Action that fires on key down. If the username is not the cached username,
229-
it sets `isChecking` to true.
230-
231-
@method keyDown
232-
*/
233-
keyDown() {
234-
once(this, '_check');
235-
if (get(this, 'isNotSameUsername')) {
236-
set(this, 'isChecking', true);
237-
}
238-
}
239-
},
240-
241232
_check() {
242233
set(this, 'isChecking', true);
243234

app/templates/components/signup-email-input.hbs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<span class="input-label__text">Your email</span>
44
</label>
55
</div>
6-
{{input name="email" autocapitalize="off" type="text" value=user.email key-down="keyDown"}}
6+
{{input name="email" autocapitalize="off" type="text" value=user.email}}
77
<div class="suggestions">
88
{{#if canShowValidations}}
99
{{#if isOkay}}

app/templates/components/signup-username-input.hbs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
</label>
55
</div>
66
{{#auto-focus}}
7-
{{input name="username" autocapitalize="off" autofocus=true tabindex=0 type="text" value=user.username key-down="keyDown"}}
7+
{{input name="username" autocapitalize="off" autofocus=true tabindex=0 type="text" value=user.username}}
88
{{/auto-focus}}
99
<div class="suggestions">
1010
{{#if canShowValidations}}

yarn.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3001,7 +3001,7 @@ ember-cli-normalize-entity-name@^1.0.0:
30013001
dependencies:
30023002
silent-error "^1.0.0"
30033003

3004-
ember-cli-page-object@^1.13.0:
3004+
30053005
version "1.13.0"
30063006
resolved "https://registry.yarnpkg.com/ember-cli-page-object/-/ember-cli-page-object-1.13.0.tgz#9ac9342d9f90a363c429fbb14f3ad5c0be11827a"
30073007
dependencies:

0 commit comments

Comments
 (0)