Skip to content

Commit ac39051

Browse files
committed
feat(auth): add confirm password to signup and settings
Originally submitted by @thomporter Closes #484
1 parent 06d0d28 commit ac39051

File tree

9 files changed

+74
-9
lines changed

9 files changed

+74
-9
lines changed

Diff for: app/generator.js

+1
Original file line numberDiff line numberDiff line change
@@ -374,6 +374,7 @@ export default class Generator extends Base {
374374
if(this.filters.socketio) angModules.push("'btford.socket-io'");
375375
if(this.filters.uirouter) angModules.push("'ui.router'");
376376
if(this.filters.uibootstrap) angModules.push("'ui.bootstrap'");
377+
if(this.filters.auth) angModules.push("'validation.match'");
377378

378379
this.angularModules = '\n ' + angModules.join(',\n ') +'\n';
379380
}

Diff for: app/templates/_bower.json

+5-4
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,19 @@
44
"dependencies": {
55
"angular": "~1.4.0",
66
"json3": "~3.3.1",
7-
"es5-shim": "~3.0.1",<% if(filters.bootstrap) { %><% if (filters.sass) { %>
7+
"es5-shim": "~3.0.1",<% if(filters.bootstrap) { if (filters.sass) { %>
88
"bootstrap-sass-official": "~3.1.1",<% } %>
99
"bootstrap": "~3.1.1",<% } %>
1010
"angular-resource": "~1.4.0",
1111
"angular-cookies": "~1.4.0",
1212
"angular-sanitize": "~1.4.0",<% if (filters.ngroute) { %>
13-
"angular-route": "~1.4.0",<% } %><% if (filters.uibootstrap) { %>
13+
"angular-route": "~1.4.0",<% } if (filters.uibootstrap) { %>
1414
"angular-bootstrap": "~0.13.0",<% } %>
1515
"font-awesome": ">=4.1.0",
1616
"lodash": "~2.4.1"<% if(filters.socketio) { %>,
17-
"angular-socket-io": "~0.7.0"<% } %><% if(filters.uirouter) { %>,
18-
"angular-ui-router": "~0.2.15"<% } %>
17+
"angular-socket-io": "~0.7.0"<% } if (filters.uirouter) { %>,
18+
"angular-ui-router": "~0.2.15"<% } if (filters.auth) { %>,
19+
"angular-validation-match": "~1.5.2"<% } %>
1920
},
2021
"devDependencies": {
2122
"angular-mocks": "~1.4.0"

Diff for: app/templates/client/app/account(auth)/settings/settings(html).html

+14
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,20 @@ <h1>Change Password</h1>
3030
</p>
3131
</div>
3232

33+
<div class="form-group">
34+
<label>Confirm New Password</label>
35+
36+
<input type="password" name="confirmPassword" class="form-control" ng-model="user.confirmPassword"
37+
match="user.newPassword"
38+
ng-minlength="3"
39+
required=""/>
40+
<p class="help-block"
41+
ng-show="form.confirmPassword.$error.match && submitted">
42+
Passwords must match.
43+
</p>
44+
45+
</div>
46+
3347
<p class="help-block"> {{ message }} </p>
3448

3549
<button class="btn btn-lg btn-primary" type="submit">Save changes</button>

Diff for: app/templates/client/app/account(auth)/settings/settings(jade).jade

+17-2
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,29 @@ navbar
77
form.form(name='form', ng-submit='changePassword(form)', novalidate='')
88
.form-group
99
label Current Password
10-
input.form-control(type='password', name='password', ng-model='user.oldPassword', mongoose-error='')
10+
input.form-control(type='password'
11+
name='password'
12+
ng-model='user.oldPassword'
13+
mongoose-error='')
1114
p.help-block(ng-show='form.password.$error.mongoose')
1215
| {{ errors.other }}
1316
.form-group
1417
label New Password
15-
input.form-control(type='password', name='newPassword', ng-model='user.newPassword', ng-minlength='3', required='')
18+
input.form-control(type='password'
19+
name='newPassword'
20+
ng-model='user.newPassword'
21+
ng-minlength='3', required='')
1622
p.help-block(ng-show='(form.newPassword.$error.minlength || form.newPassword.$error.required) && (form.newPassword.$dirty || submitted)')
1723
| Password must be at least 3 characters.
24+
.form-group
25+
label Confirm New Password
26+
input.form-control(type='password'
27+
name='confirmPassword'
28+
ng-model='user.confirmPassword'
29+
match="user.newPassword"
30+
ng-minlength='3', required='')
31+
p.help-block(ng-show='form.confirmPassword.$error.match && submitted')
32+
| Passwords must match.
1833

1934
p.help-block {{ message }}
2035

Diff for: app/templates/client/app/account(auth)/signup/signup(html).html

+12
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,18 @@ <h1>Sign up</h1>
5454
</p>
5555
</div>
5656

57+
<div class="form-group" ng-class="{ 'has-success': form.confirmPassword.$valid && submitted,
58+
'has-error': form.confirmPassword.$invalid && submitted }">
59+
<label>Confirm Password</label>
60+
<input type="password" name="confirmPassword" class="form-control" ng-model="user.confirmPassword"
61+
match="user.password"
62+
ng-minlength="3" required/>
63+
<p class="help-block"
64+
ng-show="form.confirmPassword.$error.match && submitted">
65+
Passwords must match.
66+
</p>
67+
</div>
68+
5769
<div>
5870
<button class="btn btn-inverse btn-lg btn-register" type="submit">
5971
Sign up

Diff for: app/templates/client/app/account(auth)/signup/signup(jade).jade

+16-1
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,27 @@ navbar
2626
.form-group(ng-class='{ "has-success": form.password.$valid && submitted,\
2727
"has-error": form.password.$invalid && submitted }')
2828
label Password
29-
input.form-control(type='password', name='password', ng-model='user.password', ng-minlength='3', required='', mongoose-error='')
29+
input.form-control(type='password'
30+
name='password'
31+
ng-model='user.password'
32+
mongoose-error=''
33+
ng-minlength='3', required='')
3034
p.help-block(ng-show='(form.password.$error.minlength || form.password.$error.required) && submitted')
3135
| Password must be at least 3 characters.
3236
p.help-block(ng-show='form.password.$error.mongoose')
3337
| {{ errors.password }}
3438

39+
.form-group(ng-class='{ "has-success": form.confirmPassword.$valid && submitted,\
40+
"has-error": form.confirmPassword.$invalid && submitted }')
41+
label Confirm Password
42+
input.form-control(type='password'
43+
name='confirmPassword'
44+
ng-model='user.confirmPassword'
45+
match="user.password"
46+
ng-minlength='3', required='')
47+
p.help-block(ng-show='form.confirmPassword.$error.match && submitted')
48+
| Passwords must match.
49+
3550
div
3651
button.btn.btn-inverse.btn-lg.btn-register(type='submit')
3752
| Sign up

Diff for: app/templates/e2e/account(auth)/signup/signup.po.js

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ var SignupPage = function() {
1010
this.form.name = this.form.element(by.model('user.name'));
1111
this.form.email = this.form.element(by.model('user.email'));
1212
this.form.password = this.form.element(by.model('user.password'));
13+
this.form.confirmPassword = this.form.element(by.model('user.confirmPassword'))
1314
this.form.submit = this.form.element(by.css('.btn-register'));
1415

1516
this.signup = function(data) {

Diff for: app/templates/e2e/account(auth)/signup/signup.spec(jasmine).js

+4-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ describe('Signup View', function() {
1616
var testUser = {
1717
name: 'Test',
1818
19-
password: 'test'
19+
password: 'test',
20+
confirmPassword: 'test'
2021
};
2122

2223
beforeEach(function() {
@@ -30,6 +31,8 @@ describe('Signup View', function() {
3031
expect(page.form.email.getAttribute('name')).toBe('email');
3132
expect(page.form.password.getAttribute('type')).toBe('password');
3233
expect(page.form.password.getAttribute('name')).toBe('password');
34+
expect(page.form.confirmPassword.getAttribute('type')).toBe('password');
35+
expect(page.form.confirmPassword.getAttribute('name')).toBe('confirmPassword');
3336
expect(page.form.submit.getAttribute('type')).toBe('submit');
3437
expect(page.form.submit.getText()).toBe('Sign up');
3538
});

Diff for: app/templates/e2e/account(auth)/signup/signup.spec(mocha).js

+4-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ describe('Signup View', function() {
1616
var testUser = {
1717
name: 'Test',
1818
19-
password: 'test'
19+
password: 'test',
20+
confirmPassword: 'test'
2021
};
2122

2223
before(function() {
@@ -35,6 +36,8 @@ describe('Signup View', function() {
3536
<%= expect() %>page.form.email.getAttribute('name')<%= to() %>.eventually.equal('email');
3637
<%= expect() %>page.form.password.getAttribute('type')<%= to() %>.eventually.equal('password');
3738
<%= expect() %>page.form.password.getAttribute('name')<%= to() %>.eventually.equal('password');
39+
<%= expect() %>page.form.confirmPassword.getAttribute('type')<%= to() %>.eventually.equal('password');
40+
<%= expect() %>page.form.confirmPassword.getAttribute('name')<%= to() %>.eventually.equal('confirmPassword');
3841
<%= expect() %>page.form.submit.getAttribute('type')<%= to() %>.eventually.equal('submit');
3942
<%= expect() %>page.form.submit.getText()<%= to() %>.eventually.equal('Sign up');
4043
});

0 commit comments

Comments
 (0)