From 5ee845f0b4ef859de26c74c235fb720d4cef8539 Mon Sep 17 00:00:00 2001 From: Thomas Porter Date: Fri, 22 Aug 2014 01:21:13 -0400 Subject: [PATCH 1/2] feat(auth) confirm password This is something important to my clients, so I thought it would be good to add it to the generator. Also adding the attribute to labels w/ associated IDs on inputs so clicking labels will do as they should - focus the input. Changes: adding bower dep for angular-confirm-field (https://github.com/wongatech/angular-confirm-field) adding angular dependency 'ng.confirmField' to app/index.js adding confirm password fields to signup pages (html & jade) adding attribute to labels with matching ids on their corresponding inputs repeating previous 2 steps for settings pages (html & jade) --- app/index.js | 1 + app/templates/_bower.json | 3 ++- .../settings/settings(html).html | 22 ++++++++++++++-- .../settings/settings(jade).jade | 15 ++++++++--- .../account(auth)/signup/signup(html).html | 26 ++++++++++++++++--- .../account(auth)/signup/signup(jade).jade | 20 +++++++++----- 6 files changed, 71 insertions(+), 16 deletions(-) diff --git a/app/index.js b/app/index.js index f80b370db..aba0daacd 100644 --- a/app/index.js +++ b/app/index.js @@ -248,6 +248,7 @@ var AngularFullstackGenerator = yeoman.generators.Base.extend({ if(this.filters.socketio) angModules.push("'btford.socket-io'"); if(this.filters.uirouter) angModules.push("'ui.router'"); if(this.filters.uibootstrap) angModules.push("'ui.bootstrap'"); + if(this.filters.auth) angModules.push("'ng.confirmField'"); this.angularModules = "\n " + angModules.join(",\n ") +"\n"; }, diff --git a/app/templates/_bower.json b/app/templates/_bower.json index 1681050a2..46fac9b66 100644 --- a/app/templates/_bower.json +++ b/app/templates/_bower.json @@ -16,7 +16,8 @@ "font-awesome": ">=4.1.0", "lodash": "~2.4.1"<% if(filters.socketio) { %>, "angular-socket-io": "~0.6.0"<% } %><% if(filters.uirouter) { %>, - "angular-ui-router": "~0.2.10"<% } %> + "angular-ui-router": "~0.2.10"<% } %><% if(filters.auth) { %>, + "angular-confirm-field": "~0.1.2"<% } %> }, "devDependencies": { "angular-mocks": ">=1.2.*", diff --git a/app/templates/client/app/account(auth)/settings/settings(html).html b/app/templates/client/app/account(auth)/settings/settings(html).html index bb5d8ded0..52c91c7b3 100644 --- a/app/templates/client/app/account(auth)/settings/settings(html).html +++ b/app/templates/client/app/account(auth)/settings/settings(html).html @@ -9,9 +9,10 @@

Change Password

- +

{{ errors.other }} @@ -19,9 +20,10 @@

Change Password

- +

Change Password

+ +
+ + + +

+ Passwords must match. +

+
+

{{ message }}

diff --git a/app/templates/client/app/account(auth)/settings/settings(jade).jade b/app/templates/client/app/account(auth)/settings/settings(jade).jade index 2dc55d402..36f0d5c6e 100644 --- a/app/templates/client/app/account(auth)/settings/settings(jade).jade +++ b/app/templates/client/app/account(auth)/settings/settings(jade).jade @@ -6,16 +6,23 @@ div(ng-include='"components/navbar/navbar.html"') .col-sm-12 form.form(name='form', ng-submit='changePassword(form)', novalidate='') .form-group - label Current Password - input.form-control(type='password', name='password', ng-model='user.oldPassword', mongoose-error='') + label(for="password") Current Password + input.form-control#password(type='password', name='password', ng-model='user.oldPassword', mongoose-error='') p.help-block(ng-show='form.password.$error.mongoose') | {{ errors.other }} .form-group - label New Password - input.form-control(type='password', name='newPassword', ng-model='user.newPassword', ng-minlength='3', required='') + label(for="newPassword") New Password + input.form-control#newPassword(type='password', name='newPassword', ng-model='user.newPassword', ng-minlength='3', required='') p.help-block(ng-show='(form.newPassword.$error.minlength || form.newPassword.$error.required) && (form.newPassword.$dirty || submitted)') | Password must be at least 3 characters. + .form-group + label(for="passwordConfirm") Confirm New Password + input.form-control(type='password', name='passwordConfirm', ng-model='passwordConfirm', ng-minlength='3', required='\ + ', ng-confirm-field='', confirm-against="user.newPassword") + p.help-block(ng-show='form.passwordConfirm.$error.noMatch && submitted') + | Passwords must match. + p.help-block {{ message }} button.btn.btn-lg.btn-primary(type='submit') Save changes diff --git a/app/templates/client/app/account(auth)/signup/signup(html).html b/app/templates/client/app/account(auth)/signup/signup(html).html index 59faed568..5796b6789 100644 --- a/app/templates/client/app/account(auth)/signup/signup(html).html +++ b/app/templates/client/app/account(auth)/signup/signup(html).html @@ -10,9 +10,10 @@

Sign up

- +

A name is required @@ -21,9 +22,10 @@

Sign up

- +

@@ -39,9 +41,10 @@

Sign up

- + @@ -54,6 +57,23 @@

Sign up

+
+ + + +

+ Passwords must match. +

+ +
+