Skip to content

Commit 2d8a6ec

Browse files
committed
feat(auth) add confirm password to signup and settings
confirm password powered by directive: https://github.com/wongatech/angular-confirm-field + adding for attribute to labels and ids to associated elements + fixing invalid password error in settings HTML to ref pwd.old. instead of form.password... (Jade was ok) take note of new dependency in test/fixtures/bower.json (re-run bower install on current clones...)
1 parent 16f928b commit 2d8a6ec

File tree

8 files changed

+86
-34
lines changed

8 files changed

+86
-34
lines changed

Diff for: app/index.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,7 @@ var AngularFullstackGenerator = yeoman.generators.Base.extend({
248248
if(this.filters.socketio) angModules.push("'btford.socket-io'");
249249
if(this.filters.uirouter) angModules.push("'ui.router'");
250250
if(this.filters.uibootstrap) angModules.push("'ui.bootstrap'");
251+
if(this.filters.auth) angModules.push("'ng.confirmField'");
251252

252253
this.angularModules = "\n " + angModules.join(",\n ") +"\n";
253254
},
@@ -264,4 +265,4 @@ var AngularFullstackGenerator = yeoman.generators.Base.extend({
264265
}
265266
});
266267

267-
module.exports = AngularFullstackGenerator;
268+
module.exports = AngularFullstackGenerator;

Diff for: app/templates/_bower.json

+3-2
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,11 @@
1616
"font-awesome": ">=4.1.0",
1717
"lodash": "~2.4.1"<% if(filters.socketio) { %>,
1818
"angular-socket-io": "~0.6.0"<% } %><% if(filters.uirouter) { %>,
19-
"angular-ui-router": "~0.2.10"<% } %>
19+
"angular-ui-router": "~0.2.10"<% } %><% if(filters.auth) { %>,
20+
"angular-confirm-field": "~0.1.2"<% } %>
2021
},
2122
"devDependencies": {
2223
"angular-mocks": ">=1.2.*",
2324
"angular-scenario": ">=1.2.*"
2425
}
25-
}
26+
}

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

+22-7
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ <h1>Email</h1>
99
<form role="form" name="email" ng-submit="changeEmail()" novalidate>
1010

1111
<div class="form-group has-feedback">
12-
<label>Current Email</label>
13-
<input type="email" name="email" class="form-control" ng-model="user.email" placeholder='ex. [email protected]' />
12+
<label for="email">Current Email</label>
13+
<input type="email" id="email" name="email" class="form-control" ng-model="user.email" placeholder='ex. [email protected]' />
1414
<p class="help-block" ng-show="!email.email.$valid">
1515
| Email not valid
1616
</p>
@@ -28,19 +28,19 @@ <h1><% if (filters.oauth) { %>{{ user.localEnabled ? 'Change' : 'Set' }}<% } els
2828
<form name="pwd" ng-submit="<% if(filters.oauth) { %>!user.localEnabled ? setPassword() : <% } %>changePassword()" novalidate>
2929

3030
<div class="form-group">
31-
<label>Current Password</label>
31+
<label for="oldPass">Current Password</label>
3232

33-
<input type="password" name="old" placeholder='ex. password123' class="form-control" ng-model="user.oldPassword"
33+
<input type="password" id="oldPass" name="old" placeholder='ex. password123' class="form-control" ng-model="user.oldPassword"
3434
mongoose-error <% if (filters.oauth) { %>ng-disabled='!user.localEnabled' <% } %>/>
35-
<p class="help-block" ng-show="form.password.$error.mongoose">
35+
<p class="help-block" ng-show="pwd.old.$error.mongoose">
3636
{{ errors.other }}
3737
</p>
3838
</div>
3939

4040
<div class="form-group">
41-
<label>New Password</label>
41+
<label for="newPass">New Password</label>
4242

43-
<input type="password" name="new" placeholder='ex. GoofyM1ckeyDonald&Pluto' class="form-control" ng-model="user.newPassword"
43+
<input type="password" id="newPass" name="new" placeholder='ex. GoofyM1ckeyDonald&Pluto' class="form-control" ng-model="user.newPassword"
4444
ng-minlength="3"
4545
required />
4646
<p class="help-block"
@@ -49,6 +49,21 @@ <h1><% if (filters.oauth) { %>{{ user.localEnabled ? 'Change' : 'Set' }}<% } els
4949
</p>
5050
</div>
5151

52+
<div class="form-group">
53+
<label for="passwordConfirm">Confirm New Password</label>
54+
55+
<input type="password" id="passwordConfirm" name="passwordConfirm" class="form-control"
56+
ng-model="passwordConfirm"
57+
ng-confirm-field
58+
confirm-against="user.newPassword"
59+
ng-minlength="3"
60+
required />
61+
<p class="help-block"
62+
ng-show="pwd.passwordConfirm.$error.noMatch && pwd.submitted">
63+
Passwords must match.
64+
</p>
65+
</div>
66+
5267
<p class="help-block"> {{ message }} </p>
5368

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

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

+14-7
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ div(ng-include='"components/navbar/navbar.html"')
88
form(role='form', name='email', ng-submit='changeEmail()', novalidate)
99

1010
.form-group.has-feedback
11-
label Current Email
12-
input.form-control(type='email', name='email', ng-model='user.email', placeholder='ex. [email protected]')
11+
label(for="email") Current Email
12+
input.form-control#email(type='email', name='email', ng-model='user.email', placeholder='ex. [email protected]')
1313
span.glyphicon.glyphicon-ok.form-control-feedback(ng-if='email.confirmed', title='email confirmed')
1414
p.help-block(ng-show='!email.email.$valid')
1515
| Email not valid
@@ -24,17 +24,24 @@ div(ng-include='"components/navbar/navbar.html"')
2424
form(role='form', name='pwd', ng-submit='<% if(filters.oauth) { %>!user.localEnabled ? setPassword() : <% } %>changePassword()', novalidate)
2525

2626
.form-group
27-
label Current Password
28-
input.form-control(type='password', name='old', placeholder='ex. password123', ng-model='user.oldPassword', <% if (filters.oauth) { %>ng-disabled='!user.localEnabled', <% } %>mongoose-error='')
27+
label(for="oldPass") Current Password
28+
input.form-control#oldPass(type='password', name='old', placeholder='ex. password123', ng-model='user.oldPassword', <% if (filters.oauth) { %>ng-disabled='!user.localEnabled', <% } %>mongoose-error='')
2929
p.help-block(ng-show='pwd.old.$error.mongoose')
3030
| {{ errors.other }}
3131

3232
.form-group
33-
label New Password
34-
input.form-control(type='password', name='new', placeholder='ex. GoofyM1ckeyDonald&Pluto', ng-model='user.newPassword', ng-minlength='3', required)
33+
label(for="newPass") New Password
34+
input.form-control#newPass(type='password', name='new', placeholder='ex. GoofyM1ckeyDonald&Pluto', ng-model='user.newPassword', ng-minlength='3', required)
3535
p.help-block(ng-show='(pwd.new.$error.minlength || pwd.new.$error.required) && (pwd.new.$dirty || pwd.submitted)')
3636
| Password must be at least 3 characters.
3737

38+
.form-group
39+
label(for="passwordConfirm") Confirm New Password
40+
input.form-control#passwordConfirm(type='password', name='passwordConfirm', ng-model='passwordConfirm', ng-minlength='3', required='\
41+
', ng-confirm-field='', confirm-against="user.newPassword")
42+
p.help-block(ng-show='form.passwordConfirm.$error.noMatch && pwd.submitted')
43+
| Passwords must match.
44+
3845
p.help-block {{ message }}
3946

4047
button.btn.btn-lg.btn-primary(type='submit') Save changes
@@ -45,4 +52,4 @@ div(ng-include='"components/navbar/navbar.html"')
4552
//- h1 Social accounts
4653
4754
//- .col-sm-12
48-
<% } %>
55+
<% } %>

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

+24-6
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ <h1>Sign up</h1>
1010

1111
<div class="form-group" ng-class="{ 'has-success': form.name.$valid && submitted,
1212
'has-error': form.name.$invalid && submitted }">
13-
<label>Name</label>
13+
<label for="name">Name</label>
1414

15-
<input type="text" name="name" class="form-control" ng-model="user.name"
15+
<input type="text" id="name" name="name" class="form-control" ng-model="user.name"
1616
required/>
1717
<p class="help-block" ng-show="form.name.$error.required && submitted">
1818
A name is required
@@ -21,9 +21,9 @@ <h1>Sign up</h1>
2121

2222
<div class="form-group" ng-class="{ 'has-success': form.email.$valid && submitted,
2323
'has-error': form.email.$invalid && submitted }">
24-
<label>Email</label>
24+
<label for="email">Email</label>
2525

26-
<input type="email" name="email" class="form-control" ng-model="user.email"
26+
<input type="email" id="email" name="email" class="form-control" ng-model="user.email"
2727
required
2828
mongoose-error/>
2929
<p class="help-block" ng-show="form.email.$error.email && submitted">
@@ -39,9 +39,10 @@ <h1>Sign up</h1>
3939

4040
<div class="form-group" ng-class="{ 'has-success': form.password.$valid && submitted,
4141
'has-error': form.password.$invalid && submitted }">
42-
<label>Password</label>
42+
<label for="password">Password</label>
4343

4444
<input type="password" name="password" class="form-control" ng-model="user.password"
45+
id="password"
4546
ng-minlength="3"
4647
required
4748
mongoose-error/>
@@ -54,6 +55,23 @@ <h1>Sign up</h1>
5455
</p>
5556
</div>
5657

58+
<div class="form-group" ng-class="{ 'has-success': form.passwordConfirm.$valid && submitted,
59+
'has-error': form.passwordConfirm.$invalid && submitted }">
60+
<label for="passwordConfirm">Confirm Password</label>
61+
62+
<input type="password" name="passwordConfirm" class="form-control" ng-model="passwordConfirm"
63+
id="passwordConfirm"
64+
ng-minlength="3"
65+
ng-confirm-field
66+
confirm-against="user.password"
67+
required/>
68+
<p class="help-block"
69+
ng-show="form.passwordConfirm.$error.noMatch && submitted">
70+
Passwords must match.
71+
</p>
72+
73+
</div>
74+
5775
<div>
5876
<button class="btn btn-inverse btn-lg btn-login" type="submit">
5977
Sign up
@@ -79,4 +97,4 @@ <h1>Sign up</h1>
7997
</div>
8098
</div>
8199
<hr>
82-
</div>
100+
</div>

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

+15-7
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,15 @@ div(ng-include='"components/navbar/navbar.html"')
77
form.form(name='form', ng-submit='register(form)', novalidate='')
88
.form-group(ng-class='{ "has-success": form.name.$valid && submitted,\
99
"has-error": form.name.$invalid && submitted }')
10-
label Name
11-
input.form-control(type='text', name='name', ng-model='user.name', required='')
10+
label(for="name") Name
11+
input.form-control#name(type='text', name='name', ng-model='user.name', required='')
1212
p.help-block(ng-show='form.name.$error.required && submitted')
1313
| A name is required
1414

1515
.form-group(ng-class='{ "has-success": form.email.$valid && submitted,\
1616
"has-error": form.email.$invalid && submitted }')
17-
label Email
18-
input.form-control(type='email', name='email', ng-model='user.email', required='', mongoose-error='')
17+
label(for="email") Email
18+
input.form-control#email(type='email', name='email', ng-model='user.email', required='', mongoose-error='')
1919
p.help-block(ng-show='form.email.$error.email && submitted')
2020
| Doesn't look like a valid email.
2121
p.help-block(ng-show='form.email.$error.required && submitted')
@@ -25,12 +25,20 @@ div(ng-include='"components/navbar/navbar.html"')
2525

2626
.form-group(ng-class='{ "has-success": form.password.$valid && submitted,\
2727
"has-error": form.password.$invalid && submitted }')
28-
label Password
29-
input.form-control(type='password', name='password', ng-model='user.password', ng-minlength='3', required='', mongoose-error='')
28+
label(for="password") Password
29+
input.form-control#password(type='password', name='password', ng-model='user.password', ng-minlength='3', required='', mongoose-error='')
3030
p.help-block(ng-show='(form.password.$error.minlength || form.password.$error.required) && submitted')
3131
| Password must be at least 3 characters.
3232
p.help-block(ng-show='form.password.$error.mongoose')
3333
| {{ errors.password }}
34+
35+
.form-group(ng-class='{ "has-success": form.passwordConfirm.$valid && submitted,\
36+
"has-error": form.passwordConfirm.$invalid && submitted }')
37+
label(for="passwordConfirm") Confirm Password
38+
input.form-control#passwordConfirm(type='password', name='passwordConfirm', ng-model='passwordConfirm', ng-minlength='3', required='', mongoose-error='\
39+
' ng-confirm-field="", confirm-against="user.password")
40+
p.help-block(ng-show='form.passwordConfirm.$error.noMatch && submitted')
41+
| Passwords must match.
3442

3543
div
3644
button.btn.btn-inverse.btn-lg.btn-login(type='submit')
@@ -54,4 +62,4 @@ div(ng-include='"components/navbar/navbar.html"')
5462
a.btn.btn-twitter(href='', ng-click='loginOauth("twitter")')
5563
i.fa.fa-twitter
5664
| Connect with Twitter<% } %><% } %>
57-
hr
65+
hr

Diff for: app/templates/karma.conf.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ module.exports = function(config) {
2121
'client/bower_components/angular-bootstrap/ui-bootstrap-tpls.js',<% } %>
2222
'client/bower_components/lodash/dist/lodash.compat.js',<% if(filters.socketio) { %>
2323
'client/bower_components/angular-socket-io/socket.js',<% } %><% if(filters.uirouter) { %>
24-
'client/bower_components/angular-ui-router/release/angular-ui-router.js',<% } %>
24+
'client/bower_components/angular-ui-router/release/angular-ui-router.js',<% } %><% if(filters.auth) { %>
25+
'client/bower_components/angular-confirm-field/app/package/js/angular-confirm-field.min.js',<% } %>
2526
'client/app/app.js',
2627
'client/app/app.coffee',
2728
'client/app/**/*.js',
@@ -78,4 +79,4 @@ module.exports = function(config) {
7879
// if true, it capture browsers, run tests and exit
7980
singleRun: false
8081
});
81-
};
82+
};

Diff for: test/fixtures/bower.json

+3-2
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,11 @@
1616
"font-awesome": ">=4.1.0",
1717
"lodash": "~2.4.1",
1818
"angular-socket-io": "~0.6.0",
19-
"angular-ui-router": "~0.2.10"
19+
"angular-ui-router": "~0.2.10",
20+
"angular-confirm-field": "~0.1.2"
2021
},
2122
"devDependencies": {
2223
"angular-mocks": ">=1.2.*",
2324
"angular-scenario": ">=1.2.*"
2425
}
25-
}
26+
}

0 commit comments

Comments
 (0)