Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion app/templates/Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -589,7 +589,10 @@ module.exports = function (grunt) {
// Compiles ES6 to JavaScript using Babel
babel: {
options: {
sourceMap: true
sourceMap: true,
optional: [
'es7.classProperties'
]
},<% if(filters.babel) { %>
client: {
files: [{
Expand Down
3 changes: 3 additions & 0 deletions app/templates/client/.jshintrc
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
"strict": true,
"trailing": true,
"smarttabs": true,
"ignoreDelimiters": [
{ "start": "start-non-standard", "end": "end-non-standard" }
],
"globals": {
"jQuery": true,
"angular": true,
Expand Down
18 changes: 12 additions & 6 deletions app/templates/client/app/account(auth)/account.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ angular.module('<%= scriptAppName %>')
$routeProvider
.when('/login', {
templateUrl: 'app/account/login/login.html',
controller: 'LoginCtrl'
controller: 'LoginController',
controllerAs: 'vm'
})
.when('/logout', {
name: 'logout',
Expand All @@ -21,11 +22,13 @@ angular.module('<%= scriptAppName %>')
})
.when('/signup', {
templateUrl: 'app/account/signup/signup.html',
controller: 'SignupCtrl'
controller: 'SignupController',
controllerAs: 'vm'
})
.when('/settings', {
templateUrl: 'app/account/settings/settings.html',
controller: 'SettingsCtrl',
controller: 'SettingsController',
controllerAs: 'vm',
authenticate: true
});
})
Expand All @@ -40,7 +43,8 @@ angular.module('<%= scriptAppName %>')
.state('login', {
url: '/login',
templateUrl: 'app/account/login/login.html',
controller: 'LoginCtrl'
controller: 'LoginController',
controllerAs: 'vm'
})
.state('logout', {
url: '/logout?referrer',
Expand All @@ -57,12 +61,14 @@ angular.module('<%= scriptAppName %>')
.state('signup', {
url: '/signup',
templateUrl: 'app/account/signup/signup.html',
controller: 'SignupCtrl'
controller: 'SignupController',
controllerAs: 'vm'
})
.state('settings', {
url: '/settings',
templateUrl: 'app/account/settings/settings.html',
controller: 'SettingsCtrl',
controller: 'SettingsController',
controllerAs: 'vm',
authenticate: true
});
})
Expand Down
12 changes: 6 additions & 6 deletions app/templates/client/app/account(auth)/login/login(html).html
Original file line number Diff line number Diff line change
Expand Up @@ -8,29 +8,29 @@ <h1>Login</h1>
<p>Admin account is <code>[email protected]</code> / <code>admin</code></p>
</div>
<div class="col-sm-12">
<form class="form" name="form" ng-submit="login(form)" novalidate>
<form class="form" name="form" ng-submit="vm.login(form)" novalidate>

<div class="form-group">
<label>Email</label>

<input type="email" name="email" class="form-control" ng-model="user.email" required>
<input type="email" name="email" class="form-control" ng-model="vm.user.email" required>
</div>

<div class="form-group">
<label>Password</label>

<input type="password" name="password" class="form-control" ng-model="user.password" required>
<input type="password" name="password" class="form-control" ng-model="vm.user.password" required>
</div>

<div class="form-group has-error">
<p class="help-block" ng-show="form.email.$error.required && form.password.$error.required && submitted">
<p class="help-block" ng-show="form.email.$error.required && form.password.$error.required && vm.submitted">
Please enter your email and password.
</p>
<p class="help-block" ng-show="form.email.$error.email && submitted">
<p class="help-block" ng-show="form.email.$error.email && vm.submitted">
Please enter a valid email.
</p>

<p class="help-block">{{ errors.other }}</p>
<p class="help-block">{{ vm.errors.other }}</p>
</div>

<div>
Expand Down
10 changes: 5 additions & 5 deletions app/templates/client/app/account(auth)/login/login(jade).jade
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,18 @@ navbar
code admin

.col-sm-12
form.form(name='form', ng-submit='login(form)', novalidate='')
form.form(name='form', ng-submit='vm.login(form)', novalidate='')
.form-group
label Email
input.form-control(type='email', name='email', ng-model='user.email')
input.form-control(type='email', name='email', ng-model='vm.user.email')
.form-group
label Password
input.form-control(type='password', name='password', ng-model='user.password')
input.form-control(type='password', name='password', ng-model='vm.user.password')

.form-group.has-error
p.help-block(ng-show='form.email.$error.required && form.password.$error.required && submitted')
p.help-block(ng-show='form.email.$error.required && form.password.$error.required && vm.submitted')
| Please enter your email and password.
p.help-block {{ errors.other }}
p.help-block {{ vm.errors.other }}

div
button.btn.btn-inverse.btn-lg.btn-login(type='submit')
Expand Down
52 changes: 31 additions & 21 deletions app/templates/client/app/account(auth)/login/login.controller.js
Original file line number Diff line number Diff line change
@@ -1,26 +1,36 @@
'use strict';

angular.module('<%= scriptAppName %>')
.controller('LoginCtrl', function($scope, Auth<% if (filters.ngroute) { %>, $location<% } %><% if (filters.uirouter) { %>, $state<% } %>) {
$scope.user = {};
$scope.errors = {};
class LoginController {
//start-non-standard
user = {};
errors = {};
submitted = false;
//end-non-standard

constructor(Auth<% if (filters.ngroute) { %>, $location<% } %><% if (filters.uirouter) { %>, $state<% } %>) {
this.Auth = Auth;<% if (filters.ngroute) { %>
this.$location = $location;<% } if (filters.uirouter) { %>
this.$state = $state;<% } %>
}

$scope.login = function(form) {
$scope.submitted = true;
login(form) {
this.submitted = true;

if (form.$valid) {
Auth.login({
email: $scope.user.email,
password: $scope.user.password
})
.then(function() {
// Logged in, redirect to home
<% if (filters.ngroute) { %>$location.path('/');<% } %><% if (filters.uirouter) { %>$state.go('main');<% } %>
})
.catch(function(err) {
$scope.errors.other = err.message;
});
}
};
if (form.$valid) {
this.Auth.login({
email: this.user.email,
password: this.user.password
})
.then(() => {
// Logged in, redirect to home
<% if (filters.ngroute) { %>this.$location.path('/');<% } %><% if (filters.uirouter) { %>this.$state.go('main');<% } %>
})
.catch(err => {
this.errors.other = err.message;
});
}
}
}

});
angular.module('<%= scriptAppName %>')
.controller('LoginController', LoginController);
Original file line number Diff line number Diff line change
Expand Up @@ -6,45 +6,45 @@
<h1>Change Password</h1>
</div>
<div class="col-sm-12">
<form class="form" name="form" ng-submit="changePassword(form)" novalidate>
<form class="form" name="form" ng-submit="vm.changePassword(form)" novalidate>

<div class="form-group">
<label>Current Password</label>

<input type="password" name="password" class="form-control" ng-model="user.oldPassword"
<input type="password" name="password" class="form-control" ng-model="vm.user.oldPassword"
mongoose-error/>
<p class="help-block" ng-show="form.password.$error.mongoose">
{{ errors.other }}
{{ vm.errors.other }}
</p>
</div>

<div class="form-group">
<label>New Password</label>

<input type="password" name="newPassword" class="form-control" ng-model="user.newPassword"
<input type="password" name="newPassword" class="form-control" ng-model="vm.user.newPassword"
ng-minlength="3"
required/>
<p class="help-block"
ng-show="(form.newPassword.$error.minlength || form.newPassword.$error.required) && (form.newPassword.$dirty || submitted)">
ng-show="(form.newPassword.$error.minlength || form.newPassword.$error.required) && (form.newPassword.$dirty || vm.submitted)">
Password must be at least 3 characters.
</p>
</div>

<div class="form-group">
<label>Confirm New Password</label>

<input type="password" name="confirmPassword" class="form-control" ng-model="user.confirmPassword"
match="user.newPassword"
<input type="password" name="confirmPassword" class="form-control" ng-model="vm.user.confirmPassword"
match="vm.user.newPassword"
ng-minlength="3"
required=""/>
<p class="help-block"
ng-show="form.confirmPassword.$error.match && submitted">
ng-show="form.confirmPassword.$error.match && vm.submitted">
Passwords must match.
</p>

</div>

<p class="help-block"> {{ message }} </p>
<p class="help-block"> {{ vm.message }} </p>

<button class="btn btn-lg btn-primary" type="submit">Save changes</button>
</form>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,33 +4,33 @@ navbar
.col-sm-12
h1 Change Password
.col-sm-12
form.form(name='form', ng-submit='changePassword(form)', novalidate='')
form.form(name='form', ng-submit='vm.changePassword(form)', novalidate='')
.form-group
label Current Password
input.form-control(type='password'
name='password'
ng-model='user.oldPassword'
ng-model='vm.user.oldPassword'
mongoose-error='')
p.help-block(ng-show='form.password.$error.mongoose')
| {{ errors.other }}
| {{ vm.errors.other }}
.form-group
label New Password
input.form-control(type='password'
name='newPassword'
ng-model='user.newPassword'
ng-model='vm.user.newPassword'
ng-minlength='3', required='')
p.help-block(ng-show='(form.newPassword.$error.minlength || form.newPassword.$error.required) && (form.newPassword.$dirty || submitted)')
p.help-block(ng-show='(form.newPassword.$error.minlength || form.newPassword.$error.required) && (form.newPassword.$dirty || vm.submitted)')
| Password must be at least 3 characters.
.form-group
label Confirm New Password
input.form-control(type='password'
name='confirmPassword'
ng-model='user.confirmPassword'
match="user.newPassword"
ng-model='vm.user.confirmPassword'
match="vm.user.newPassword"
ng-minlength='3', required='')
p.help-block(ng-show='form.confirmPassword.$error.match && submitted')
p.help-block(ng-show='fvm.orm.confirmPassword.$error.match && vm.submitted')
| Passwords must match.

p.help-block {{ message }}
p.help-block {{ vm.message }}

button.btn.btn-lg.btn-primary(type='submit') Save changes
Original file line number Diff line number Diff line change
@@ -1,21 +1,31 @@
'use strict';

angular.module('<%= scriptAppName %>')
.controller('SettingsCtrl', function($scope, User, Auth) {
$scope.errors = {};
class SettingsController {
//start-non-standard
errors = {};
submitted = false;
//end-non-standard

constructor(Auth) {
this.Auth = Auth;
}

changePassword(form) {
this.submitted = true;

$scope.changePassword = function(form) {
$scope.submitted = true;
if (form.$valid) {
Auth.changePassword($scope.user.oldPassword, $scope.user.newPassword)
.then(function() {
$scope.message = 'Password successfully changed.';
})
.catch(function() {
form.password.$setValidity('mongoose', false);
$scope.errors.other = 'Incorrect password';
$scope.message = '';
});
}
};
});
if (form.$valid) {
this.Auth.changePassword(this.user.oldPassword, this.user.newPassword)
.then(() => {
this.message = 'Password successfully changed.';
})
.catch(() => {
form.password.$setValidity('mongoose', false);
this.errors.other = 'Incorrect password';
this.message = '';
});
}
}
}

angular.module('<%= scriptAppName %>')
.controller('SettingsController', SettingsController);
Loading