Skip to content

Commit ce7f342

Browse files
committed
Revert "feat(oauth): multiple strategies per account; changeable email"
This reverts commit ef06272. Conflicts: app/templates/client/app/account(auth)/settings/settings.controller(coffee).coffee app/templates/client/app/account(auth)/settings/settings.controller(js).js app/templates/client/app/admin(auth)/admin(html).html app/templates/client/app/admin(auth)/admin(jade).jade app/templates/client/app/admin(auth)/admin.controller(coffee).coffee app/templates/client/app/admin(auth)/admin.controller(js).js app/templates/server/api/user(auth)/user.controller.js app/templates/server/api/user(auth)/user.model.js app/templates/server/auth(auth)/facebook(facebookAuth)/index.js app/templates/server/auth(auth)/facebook(facebookAuth)/passport.js app/templates/server/auth(auth)/google(googleAuth)/index.js app/templates/server/auth(auth)/google(googleAuth)/passport.js app/templates/server/config/_local.env.js app/templates/server/config/environment/index.js
1 parent 213db2f commit ce7f342

35 files changed

+388
-774
lines changed

Diff for: CHANGELOG.md

-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
* **docs:** Inform users/developers of the `canary` branch ([74693623](http://github.com/DaftMonk/generator-angular-fullstack/commit/74693623eb23c9399495a3baff7e3479a1d9f3ba))
1616
* **gen:** make generator tests faster, and easier to run ([84acb744](http://github.com/DaftMonk/generator-angular-fullstack/commit/84acb7448ccc7c55b72bdd19bfae50c33d527296))
1717
* **app:** add additional node version to travis.yml ([e4f00b08](http://github.com/DaftMonk/generator-angular-fullstack/commit/e4f00b083a880713ca563e3447b9fb3f56a54ebc))
18-
* **oauth:** multiple strategies per account; changeable email ([ef062728](http://github.com/DaftMonk/generator-angular-fullstack/commit/ef062728a2ec61d990fa87d965f2507b4bcc5b20))
1918
* **uibootstrap:** add basic modal service and template when using uibootstrap ([7c14bed4](http://github.com/DaftMonk/generator-angular-fullstack/commit/7c14bed4873b92124bcbe422fed918836b8f5df5))
2019

2120
<a name="v2.0.10"></a>

Diff for: app/index.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -149,17 +149,17 @@ var AngularFullstackGenerator = yeoman.generators.Base.extend({
149149
{
150150
value: 'googleAuth',
151151
name: 'Google',
152-
checked: true
152+
checked: false
153153
},
154154
{
155155
value: 'facebookAuth',
156156
name: 'Facebook',
157-
checked: true
157+
checked: false
158158
},
159159
{
160160
value: 'twitterAuth',
161161
name: 'Twitter',
162-
checked: true
162+
checked: false
163163
}
164164
]
165165
}, {

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

+7-34
Original file line numberDiff line numberDiff line change
@@ -3,35 +3,16 @@
33
<div class="container">
44
<div class="row">
55
<div class="col-sm-12">
6-
<h1>Email</h1>
6+
<h1>Change Password</h1>
77
</div>
88
<div class="col-sm-12">
9-
<form role="form" name="email" ng-submit="changeEmail()" novalidate>
10-
11-
<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]' />
14-
<p class="help-block" ng-show="!email.email.$valid">
15-
| Email not valid
16-
</p>
17-
</div>
18-
19-
<button class="btn btn-lg btn-primary" type="submit">Save changes</button>
20-
</form>
21-
</div>
22-
</div>
23-
<div class="row">
24-
<div class="col-sm-12">
25-
<h1><% if (filters.oauth) { %>{{ user.localEnabled ? 'Change' : 'Set' }}<% } else { %>Change<% } %> Password</h1>
26-
</div>
27-
<div class="col-sm-12">
28-
<form name="pwd" ng-submit="<% if(filters.oauth) { %>!user.localEnabled ? setPassword() : <% } %>changePassword()" novalidate>
9+
<form class="form" name="form" ng-submit="changePassword(form)" novalidate>
2910

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

33-
<input type="password" name="old" placeholder='ex. password123' class="form-control" ng-model="user.oldPassword"
34-
mongoose-error <% if (filters.oauth) { %>ng-disabled='!user.localEnabled' <% } %>/>
14+
<input type="password" name="password" class="form-control" ng-model="user.oldPassword"
15+
mongoose-error/>
3516
<p class="help-block" ng-show="form.password.$error.mongoose">
3617
{{ errors.other }}
3718
</p>
@@ -40,11 +21,11 @@ <h1><% if (filters.oauth) { %>{{ user.localEnabled ? 'Change' : 'Set' }}<% } els
4021
<div class="form-group">
4122
<label>New Password</label>
4223

43-
<input type="password" name="new" placeholder='ex. GoofyM1ckeyDonald&Pluto' class="form-control" ng-model="user.newPassword"
24+
<input type="password" name="newPassword" class="form-control" ng-model="user.newPassword"
4425
ng-minlength="3"
45-
required />
26+
required/>
4627
<p class="help-block"
47-
ng-show="(pwd.new.$error.minlength || pwd.new.$error.required) && (pwd.new.$dirty || pwd.submitted)">
28+
ng-show="(form.newPassword.$error.minlength || form.newPassword.$error.required) && (form.newPassword.$dirty || submitted)">
4829
Password must be at least 3 characters.
4930
</p>
5031
</div>
@@ -55,12 +36,4 @@ <h1><% if (filters.oauth) { %>{{ user.localEnabled ? 'Change' : 'Set' }}<% } els
5536
</form>
5637
</div>
5738
</div>
58-
<% if (filters.oauth) { %>
59-
<!-- <div class="row">
60-
<div class="col-sm-12">
61-
<h1>Social accounts</h1>
62-
</div>
63-
<div class="col-sm-12"></div>
64-
</div> -->
65-
<% } %>
6639
</div>

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

+7-34
Original file line numberDiff line numberDiff line change
@@ -2,47 +2,20 @@ div(ng-include='"components/navbar/navbar.html"')
22
.container
33
.row
44
.col-sm-12
5-
h1 Email
6-
7-
.col-sm-12
8-
form(role='form', name='email', ng-submit='changeEmail()', novalidate)
9-
10-
.form-group.has-feedback
11-
label Current Email
12-
input.form-control(type='email', name='email', ng-model='user.email', placeholder='ex. [email protected]')
13-
span.glyphicon.glyphicon-ok.form-control-feedback(ng-if='email.confirmed', title='email confirmed')
14-
p.help-block(ng-show='!email.email.$valid')
15-
| Email not valid
16-
17-
button.btn.btn-lg.btn-primary(type='submit') Save changes
18-
19-
.row
5+
h1 Change Password
206
.col-sm-12
21-
h1 <% if (filters.oauth) { %>{{ user.localEnabled ? 'Change' : 'Set' }}<% } else { %>Change<% } %> Password
22-
23-
.col-sm-12
24-
form(role='form', name='pwd', ng-submit='<% if(filters.oauth) { %>!user.localEnabled ? setPassword() : <% } %>changePassword()', novalidate)
25-
7+
form.form(name='form', ng-submit='changePassword(form)', novalidate='')
268
.form-group
279
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='')
29-
p.help-block(ng-show='pwd.old.$error.mongoose')
10+
input.form-control(type='password', name='password', ng-model='user.oldPassword', mongoose-error='')
11+
p.help-block(ng-show='form.password.$error.mongoose')
3012
| {{ errors.other }}
31-
3213
.form-group
3314
label New Password
34-
input.form-control(type='password', name='new', placeholder='ex. GoofyM1ckeyDonald&Pluto', ng-model='user.newPassword', ng-minlength='3', required)
35-
p.help-block(ng-show='(pwd.new.$error.minlength || pwd.new.$error.required) && (pwd.new.$dirty || pwd.submitted)')
15+
input.form-control(type='password', name='newPassword', ng-model='user.newPassword', ng-minlength='3', required='')
16+
p.help-block(ng-show='(form.newPassword.$error.minlength || form.newPassword.$error.required) && (form.newPassword.$dirty || submitted)')
3617
| Password must be at least 3 characters.
3718

38-
p.help-block {{ message }}
19+
p.help-block {{ message }}
3920

4021
button.btn.btn-lg.btn-primary(type='submit') Save changes
41-
42-
<% if (filters.oauth) { %>
43-
//- .row
44-
//- .col-sm-12
45-
//- h1 Social accounts
46-
47-
//- .col-sm-12
48-
<% } %>
Original file line numberDiff line numberDiff line change
@@ -1,59 +1,17 @@
11
'use strict'
22

33
angular.module '<%= scriptAppName %>'
4-
.controller 'SettingsCtrl', ($scope, Auth) ->
4+
.controller 'SettingsCtrl', ($scope, User, Auth) ->
55
$scope.errors = {}
6+
$scope.changePassword = (form) ->
7+
$scope.submitted = true
68

7-
$scope.user = Auth.getCurrentUser()
8-
$scope.email = {}
9-
10-
getEmail = (user) ->
11-
return [null, null] unless user.credentials.length
12-
13-
for c in user.credentials when c.type is 'email'
14-
return [c.value, c.confirmed]
15-
16-
[null, null]
17-
18-
[initialEmail, $scope.email.confirmed] = getEmail $scope.user
19-
20-
$scope.user.email = initialEmail
21-
22-
$scope.changeEmail = ->
23-
if $scope.email.$valid
24-
Auth.changeEmail initialEmail, $scope.user.email
25-
.then ->
26-
$scope.message = 'Email successfully changed'
27-
28-
.catch ->
29-
# TODO: handle errors
30-
$scope.message = ''
31-
32-
$scope.changePassword = ->
33-
$scope.pwd.submitted = true
34-
35-
if $scope.pwd.$valid
9+
if form.$valid
3610
Auth.changePassword $scope.user.oldPassword, $scope.user.newPassword
3711
.then ->
38-
$scope.message = 'Password successfully changed'
12+
$scope.message = 'Password successfully changed.'
3913

4014
.catch ->
41-
$scope.pwd.old.$setValidity 'mongoose', false
15+
form.password.$setValidity 'mongoose', false
4216
$scope.errors.other = 'Incorrect password'
4317
$scope.message = ''
44-
<% if (filters.oauth) { %>
45-
$scope.setPassword = ->
46-
$scope.pwd.submitted = true
47-
48-
if $scope.pwd.$valid
49-
Auth.setPassword $scope.user.newPassword
50-
.then ->
51-
$scope.message = 'Password successfully set'
52-
$scope.user.localEnabled = true
53-
$scope.user.newPassword = ''
54-
55-
.catch ->
56-
$scope.pwd.old.$setValidity 'mongoose', false
57-
$scope.errors.other = 'Another account with that email already exists'
58-
$scope.message = ''
59-
<% } %>
Original file line numberDiff line numberDiff line change
@@ -1,73 +1,21 @@
11
'use strict';
22

33
angular.module('<%= scriptAppName %>')
4-
.controller('SettingsCtrl', function ($scope, Auth) {
4+
.controller('SettingsCtrl', function ($scope, User, Auth) {
55
$scope.errors = {};
66

7-
$scope.user = Auth.getCurrentUser();
8-
$scope.email = {};
9-
10-
var getEmail = function(user) {
11-
if (!user.credentials.length) {
12-
return null;
13-
}
14-
15-
for(var i in user.credentials) {
16-
var c = user.credentials[i];
17-
if (c.type === 'email') {
18-
return [c.value, c.confirmed];
19-
}
20-
}
21-
};
22-
23-
var tmp = getEmail($scope.user);
24-
25-
var initialEmail = tmp ? tmp[0] : null;
26-
$scope.email.confirmed = tmp ? tmp[1] : null;
27-
28-
$scope.user.email = initialEmail;
29-
30-
$scope.changeEmail = function () {
31-
if($scope.email.$valid) {
32-
Auth.changeEmail(initialEmail, $scope.user.email)
33-
.then(function() {
34-
$scope.message = 'Email successfully changed';
35-
})
36-
.catch(function() {
37-
// TODO: handle errors
38-
$scope.message = '';
39-
});
40-
}
41-
};
42-
43-
$scope.changePassword = function() {
44-
$scope.pwd.submitted = true;
45-
if($scope.pwd.$valid) {
7+
$scope.changePassword = function(form) {
8+
$scope.submitted = true;
9+
if(form.$valid) {
4610
Auth.changePassword( $scope.user.oldPassword, $scope.user.newPassword )
4711
.then( function() {
48-
$scope.message = 'Password successfully changed';
12+
$scope.message = 'Password successfully changed.';
4913
})
5014
.catch( function() {
51-
$scope.pwd.old.$setValidity('mongoose', false);
15+
form.password.$setValidity('mongoose', false);
5216
$scope.errors.other = 'Incorrect password';
5317
$scope.message = '';
5418
});
5519
}
5620
};
57-
<% if (filters.oauth) { %>
58-
$scope.setPassword = function() {
59-
$scope.submitted = true;
60-
if($scope.pwd.$valid) {
61-
Auth.changePassword( $scope.user.newPassword )
62-
.then( function() {
63-
$scope.message = 'Password successfully set';
64-
})
65-
.catch( function() {
66-
$scope.pwd.old.$setValidity('mongoose', false);
67-
$scope.errors.other = 'Another account with that email already exists';
68-
$scope.message = '';
69-
});
70-
}
71-
};
72-
<% } %>
7321
});

Diff for: app/templates/client/app/admin(auth)/admin(css).css

-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1 @@
11
.trash { color:rgb(209, 91, 71); }
2-
.confirm { color:rgb(240, 173, 78); }
3-
.confirmed { color:rgb(92, 184, 92); }

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
<ul class="list-group">
66
<li class="list-group-item" ng-repeat="user in users">
77
<strong>{{user.name}}</strong><br>
8-
<span class="text-muted">{{user.credentials[0].value}}</span>
9-
<a ng-click="delete(<% if(filters.uibootstrap) { %>user.name + ' (' + user.credentials[0].value + ')', <% } %>user)" class="trash"><span class="glyphicon glyphicon-trash pull-right"></span></a>
8+
<span class="text-muted">{{user.email}}</span>
9+
<a ng-click="delete(user)" class="trash"><span class="glyphicon glyphicon-trash pull-right"></span></a>
1010
</li>
1111
</ul>
1212
</div>

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

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@ div(ng-include='"components/navbar/navbar.html"')
66
li.list-group-item(ng-repeat='user in users')
77
strong {{user.name}}
88
br
9-
span.text-muted {{user.credentials[0].value}}
10-
a.trash(ng-click='delete(<% if(filters.uibootstrap) { %>user.name + " (" + user.credentials[0].value + ")", <% } %>user)')
11-
span.glyphicon.glyphicon-trash.pull-right
9+
span.text-muted {{user.email}}
10+
a.trash(ng-click='delete(user)')
11+
span.glyphicon.glyphicon-trash.pull-right
+1-3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1 @@
1-
.trash { color:rgb(209, 91, 71); }
2-
.confirm { color:rgb(240, 173, 78); }
3-
.confirmed { color:rgb(92, 184, 92); }
1+
.trash { color:rgb(209, 91, 71); }
-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1 @@
11
.trash { color:rgb(209, 91, 71); }
2-
.confirm { color:rgb(240, 173, 78); }
3-
.confirmed { color:rgb(92, 184, 92); }
+1-7
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,2 @@
11
.trash
2-
color rgb(209, 91, 71)
3-
4-
.confirm
5-
color: rgb(240, 173, 78)
6-
7-
.confirmed
8-
color: rgb(92, 184, 92)
2+
color rgb(209, 91, 71)
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
'use strict'
22

33
angular.module '<%= scriptAppName %>'
4-
.controller 'AdminCtrl', ($scope, $http, User<% if(filters.uibootstrap) { %>, Modal<% } %>) ->
4+
.controller 'AdminCtrl', ($scope, $http, Auth, User) ->
55

6-
# Use the User $resource to fetch all users
7-
$scope.users = User.query()
6+
$http.get '/api/users'
7+
.success (users) ->
8+
$scope.users = users
89

9-
$scope.delete = <% if(filters.uibootstrap) { %>Modal.confirm.delete <% } %>(user) ->
10+
$scope.delete = (user) ->
1011
User.remove id: user._id
1112
_.remove $scope.users, user
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
11
'use strict';
22

33
angular.module('<%= scriptAppName %>')
4-
.controller('AdminCtrl', function ($scope, $http, User<% if(filters.uibootstrap) { %>, Modal<% } %>) {
4+
.controller('AdminCtrl', function ($scope, $http, Auth, User) {
55

66
// Use the User $resource to fetch all users
77
$scope.users = User.query();
88

9-
$scope.delete = <% if(filters.uibootstrap) { %>Modal.confirm.delete(<% } %>function(user) {
9+
$scope.delete = function(user) {
1010
User.remove({ id: user._id });
11-
_.remove($scope.users, user);
12-
}<% if(filters.uibootstrap) { %>)<% } %>;
11+
angular.forEach($scope.users, function(u, i) {
12+
if (u === user) {
13+
$scope.users.splice(i, 1);
14+
}
15+
});
16+
};
1317
});

0 commit comments

Comments
 (0)