Skip to content

Commit 46466b1

Browse files
committed
Merge pull request #366 from Apercu/fix/remove-oauth-code
feat(oauth): remove code according to user prompts
2 parents cb866d1 + 53e541f commit 46466b1

15 files changed

+89
-111
lines changed

app/index.js

+1
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,7 @@ var AngularFullstackGenerator = yeoman.generators.Base.extend({
166166
if(answers.mongoose) this.filters.mongoose = true;
167167
if(answers.auth) this.filters.auth = true;
168168
if(answers.oauth) {
169+
if(answers.oauth.length) this.filters.oauth = true;
169170
answers.oauth.forEach(function(oauthStrategy) {
170171
this.filters[oauthStrategy] = true;
171172
}.bind(this));
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
1-
.btn-facebook {
1+
<% if (filters.oauth) { %><% if (filters.facebookAuth) { %>.btn-facebook {
22
color: #fff;
33
background-color: #3B5998;
44
border-color: #133783;
55
}
6-
6+
<% } if (filters.twitterAuth) { %>
77
.btn-twitter {
88
color: #fff;
99
background-color: #2daddc;
1010
border-color: #0271bf;
1111
}
12-
13-
.btn-github {
14-
color: #fff;
15-
background-color: #fafafa;
16-
border-color: #ccc;
17-
}
18-
12+
<% } if (filters.googleAuth) { %>
1913
.btn-google-plus {
2014
color: #fff;
2115
background-color: #dd4b39;
2216
border-color: #c53727;
23-
}
17+
}
18+
<% } %>
19+
.btn-github {
20+
color: #fff;
21+
background-color: #fafafa;
22+
border-color: #ccc;
23+
}<% } %>

app/templates/client/app/account(auth)/login/login(html).html

+2-3
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,7 @@ <h1>Login</h1>
3737
Register
3838
</a>
3939
</div>
40-
41-
<% if(filters.facebookAuth || filters.twitterAuth || filters.googleAuth) {%>
40+
<% if(filters.oauth) {%>
4241
<hr>
4342
<div><% if(filters.facebookAuth) {%>
4443
<a class="btn btn-facebook" href="" ng-click="loginOauth('facebook')">
@@ -55,4 +54,4 @@ <h1>Login</h1>
5554
</div>
5655
</div>
5756
<hr>
58-
</div>
57+
</div>

app/templates/client/app/account(auth)/login/login(jade).jade

+1-2
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,7 @@ div(ng-include='"components/navbar/navbar.html"')
3636
= ' '
3737
a.btn.btn-default.btn-lg.btn-register(href='/signup')
3838
| Register
39-
40-
<% if(filters.facebookAuth || filters.twitterAuth || filters.googleAuth) {%>
39+
<% if(filters.oauth) {%>
4140
hr
4241

4342
div<% if(filters.facebookAuth) {%>
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,30 @@
1-
<% if(filters.bootstrap) { %>
2-
// Colors
1+
<% if(filters.bootstrap) { %>// Colors
32
// --------------------------------------------------
43

54
@btnText: #fff;
6-
@btnTextAlt: #000;
7-
5+
@btnTextAlt: #000;<% if (filters.oauth) { %>
6+
<% if (filters.facebookAuth) { %>
87
@btnFacebookBackground: #3B5998;
9-
@btnFacebookBackgroundHighlight: #133783;
10-
8+
@btnFacebookBackgroundHighlight: #133783;<% } if (filters.twitterAuth) { %>
119
@btnTwitterBackground: #2daddc;
12-
@btnTwitterBackgroundHighlight: #0271bf;
13-
10+
@btnTwitterBackgroundHighlight: #0271bf;<% } if (filters.googleAuth) { %>
11+
@btnGooglePlusBackground: #dd4b39;
12+
@btnGooglePlusBackgroundHighlight: #c53727;<% } %>
1413
@btnGithubBackground: #fafafa;
1514
@btnGithubBackgroundHighlight: #ccc;
1615

17-
@btnGooglePlusBackground: #dd4b39;
18-
@btnGooglePlusBackgroundHighlight: #c53727;
19-
20-
2116
// Social buttons
2217
// --------------------------------------------------
23-
18+
<% if (filters.facebookAuth) { %>
2419
.btn-facebook {
2520
.button-variant(@btnText; @btnFacebookBackgroundHighlight; @btnFacebookBackgroundHighlight);
26-
}
27-
21+
}<% } if (filters.twitterAuth) { %>
2822
.btn-twitter {
2923
.button-variant(@btnText; @btnTwitterBackground; @btnTwitterBackgroundHighlight);
30-
}
31-
32-
.btn-github {
33-
.button-variant(@btnTextAlt; @btnGithubBackground; @btnGithubBackgroundHighlight);
34-
}
35-
24+
}<% } if (filters.googleAuth) { %>
3625
.btn-google-plus {
3726
.button-variant(@btnText; @btnGooglePlusBackground; @btnGooglePlusBackgroundHighlight);
38-
}<% } %>
27+
}<% } %>
28+
.btn-github {
29+
.button-variant(@btnTextAlt; @btnGithubBackground; @btnGithubBackgroundHighlight);
30+
}<% } %><% } %>
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,30 @@
1-
<% if(filters.bootstrap) { %>
2-
// Colors
1+
<% if(filters.bootstrap) { %>// Colors
32
// --------------------------------------------------
43

54
$btnText: #fff;
6-
$btnTextAlt: #000;
7-
5+
$btnTextAlt: #000;<% if (filters.oauth) { %>
6+
<% if (filters.facebookAuth) { %>
87
$btnFacebookBackground: #3B5998;
9-
$btnFacebookBackgroundHighlight: #133783;
10-
8+
$btnFacebookBackgroundHighlight: #133783;<% } if (filters.twitterAuth) { %>
119
$btnTwitterBackground: #2daddc;
12-
$btnTwitterBackgroundHighlight: #0271bf;
13-
10+
$btnTwitterBackgroundHighlight: #0271bf;<% } if (filters.googleAuth) { %>
11+
$btnGooglePlusBackground: #dd4b39;
12+
$btnGooglePlusBackgroundHighlight: #c53727;<% } %>
1413
$btnGithubBackground: #fafafa;
1514
$btnGithubBackgroundHighlight: #ccc;
1615

17-
$btnGooglePlusBackground: #dd4b39;
18-
$btnGooglePlusBackgroundHighlight: #c53727;
19-
20-
2116
// Social buttons
2217
// --------------------------------------------------
23-
18+
<% if (filters.facebookAuth) { %>
2419
.btn-facebook {
2520
@include button-variant($btnText, $btnFacebookBackgroundHighlight, $btnFacebookBackgroundHighlight);
26-
}
27-
21+
}<% } if (filters.twitterAuth) { %>
2822
.btn-twitter {
2923
@include button-variant($btnText, $btnTwitterBackground, $btnTwitterBackgroundHighlight);
30-
}
31-
32-
.btn-github {
33-
@include button-variant($btnTextAlt, $btnGithubBackground, $btnGithubBackgroundHighlight);
34-
}
35-
24+
}<% } if (filters.googleAuth) { %>
3625
.btn-google-plus {
3726
@include button-variant($btnText, $btnGooglePlusBackground, $btnGooglePlusBackgroundHighlight);
38-
}<% } %>
27+
}<% } %>
28+
.btn-github {
29+
@include button-variant($btnTextAlt, $btnGithubBackground, $btnGithubBackgroundHighlight);
30+
}<% } %><% } %>
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
1-
// Social buttons
1+
<% if (filters.oauth) { %>// Social buttons
22
// --------------------------------------------------
3-
3+
<% if (filters.facebookAuth) { %>
44
.btn-facebook
55
color: #fff;
66
background-color: #3B5998;
77
border-color: #133783;
8-
8+
<% } if (filters.twitterAuth) { %>
99
.btn-twitter
1010
color: #fff;
1111
background-color: #2daddc;
1212
border-color: #0271bf;
13-
14-
.btn-github
15-
color: #fff;
16-
background-color: #fafafa;
17-
border-color: #ccc;
18-
13+
<% } if (filters.googleAuth) { %>
1914
.btn-google-plus
2015
color: #fff;
2116
background-color: #dd4b39;
22-
border-color: #c53727;
17+
border-color: #c53727;
18+
<% } %>
19+
.btn-github
20+
color: #fff;
21+
background-color: #fafafa;
22+
border-color: #ccc;<% } %>

app/templates/client/app/account(auth)/login/login.controller(coffee).coffee

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
'use strict'
22

33
angular.module '<%= scriptAppName %>'
4-
.controller 'LoginCtrl', ($scope, Auth, $location, $window) ->
4+
.controller 'LoginCtrl', ($scope, Auth, $location<% if(filters.oauth) {%>, $window<% } %>) ->
55
$scope.user = {}
66
$scope.errors = {}
77
$scope.login = (form) ->
@@ -18,6 +18,6 @@ angular.module '<%= scriptAppName %>'
1818

1919
.catch (err) ->
2020
$scope.errors.other = err.message
21-
21+
<% if(filters.oauth) {%>
2222
$scope.loginOauth = (provider) ->
23-
$window.location.href = '/auth/' + provider
23+
$window.location.href = '/auth/' + provider<% } %>

app/templates/client/app/account(auth)/login/login.controller(js).js

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
'use strict';
22

33
angular.module('<%= scriptAppName %>')
4-
.controller('LoginCtrl', function ($scope, Auth, $location, $window) {
4+
.controller('LoginCtrl', function ($scope, Auth, $location<% if (filters.oauth) { %>, $window<% } %>) {
55
$scope.user = {};
66
$scope.errors = {};
77

@@ -22,8 +22,8 @@ angular.module('<%= scriptAppName %>')
2222
});
2323
}
2424
};
25-
25+
<% if(filters.oauth) {%>
2626
$scope.loginOauth = function(provider) {
2727
$window.location.href = '/auth/' + provider;
28-
};
28+
};<% } %>
2929
});

app/templates/client/app/account(auth)/signup/signup(html).html

+1-2
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,7 @@ <h1>Sign up</h1>
6262
Login
6363
</a>
6464
</div>
65-
66-
<% if(filters.facebookAuth || filters.twitterAuth || filters.googleAuth) {%>
65+
<% if(filters.oauth) {%>
6766
<hr>
6867
<div><% if(filters.facebookAuth) {%>
6968
<a class="btn btn-facebook" href="" ng-click="loginOauth('facebook')">

app/templates/client/app/account(auth)/signup/signup(jade).jade

+1-2
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,7 @@ div(ng-include='"components/navbar/navbar.html"')
3939
a.btn.btn-default.btn-lg.btn-register(href='/login')
4040
| Login
4141

42-
43-
<% if(filters.facebookAuth || filters.twitterAuth || filters.googleAuth) {%>
42+
<% if(filters.oauth) {%>
4443
hr
4544

4645
div<% if(filters.facebookAuth) {%>

app/templates/client/app/account(auth)/signup/signup.controller(coffee).coffee

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
'use strict'
22

33
angular.module '<%= scriptAppName %>'
4-
.controller 'SignupCtrl', ($scope, Auth, $location, $window) ->
4+
.controller 'SignupCtrl', ($scope, Auth, $location<% if(filters.oauth) {%>, $window<% } %>) ->
55
$scope.user = {}
66
$scope.errors = {}
77
$scope.register = (form) ->
@@ -25,6 +25,6 @@ angular.module '<%= scriptAppName %>'
2525
angular.forEach err.errors, (error, field) ->
2626
form[field].$setValidity 'mongoose', false
2727
$scope.errors[field] = error.message
28-
28+
<% if(filters.oauth) {%>
2929
$scope.loginOauth = (provider) ->
30-
$window.location.href = '/auth/' + provider
30+
$window.location.href = '/auth/' + provider<% } %>

app/templates/client/app/account(auth)/signup/signup.controller(js).js

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
'use strict';
22

33
angular.module('<%= scriptAppName %>')
4-
.controller('SignupCtrl', function ($scope, Auth, $location, $window) {
4+
.controller('SignupCtrl', function ($scope, Auth, $location<% if (filters.oauth) { %>, $window<% } %>) {
55
$scope.user = {};
66
$scope.errors = {};
77

@@ -30,8 +30,8 @@ angular.module('<%= scriptAppName %>')
3030
});
3131
}
3232
};
33-
33+
<% if(filters.oauth) {%>
3434
$scope.loginOauth = function(provider) {
3535
$window.location.href = '/auth/' + provider;
36-
};
36+
};<% } %>
3737
});

app/templates/server/api/user(auth)/user.model.js

+12-15
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,8 @@
22

33
var mongoose = require('mongoose');
44
var Schema = mongoose.Schema;
5-
var crypto = require('crypto');
6-
7-
var authTypes = ['github', 'twitter', 'facebook', 'google'];
5+
var crypto = require('crypto');<% if(filters.oauth) { %>
6+
var authTypes = ['github', 'twitter', 'facebook', 'google'];<% } %>
87

98
var UserSchema = new Schema({
109
name: String,
@@ -15,11 +14,11 @@ var UserSchema = new Schema({
1514
},
1615
hashedPassword: String,
1716
provider: String,
18-
salt: String,
19-
facebook: {},
20-
twitter: {},
21-
github: {},
22-
google: {}
17+
salt: String<% if (filters.oauth) { %>,<% if (filters.facebookAuth) { %>
18+
facebook: {},<% } %><% if (filters.twitterAuth) { %>
19+
twitter: {},<% } %><% if (filters.googleAuth) { %>
20+
google: {},<% } %>
21+
github: {}<% } %>
2322
});
2423

2524
/**
@@ -63,18 +62,16 @@ UserSchema
6362
// Validate empty email
6463
UserSchema
6564
.path('email')
66-
.validate(function(email) {
67-
// if you are authenticating by any of the oauth strategies, don't validate
68-
if (authTypes.indexOf(this.provider) !== -1) return true;
65+
.validate(function(email) {<% if (filters.oauth) { %>
66+
if (authTypes.indexOf(this.provider) !== -1) return true;<% } %>
6967
return email.length;
7068
}, 'Email cannot be blank');
7169

7270
// Validate empty password
7371
UserSchema
7472
.path('hashedPassword')
75-
.validate(function(hashedPassword) {
76-
// if you are authenticating by any of the oauth strategies, don't validate
77-
if (authTypes.indexOf(this.provider) !== -1) return true;
73+
.validate(function(hashedPassword) {<% if (filters.oauth) { %>
74+
if (authTypes.indexOf(this.provider) !== -1) return true;<% } %>
7875
return hashedPassword.length;
7976
}, 'Password cannot be blank');
8077

@@ -104,7 +101,7 @@ UserSchema
104101
.pre('save', function(next) {
105102
if (!this.isNew) return next();
106103

107-
if (!validatePresenceOf(this.hashedPassword) && authTypes.indexOf(this.provider) === -1)
104+
if (!validatePresenceOf(this.hashedPassword)<% if (filters.oauth) { %> && authTypes.indexOf(this.provider) === -1<% } %>)
108105
next(new Error('Invalid password'));
109106
else
110107
next();

0 commit comments

Comments
 (0)