Skip to content

feat(oauth): remove code according to user prompts #366

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jul 22, 2014
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
1 change: 1 addition & 0 deletions app/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ var AngularFullstackGenerator = yeoman.generators.Base.extend({
if(answers.mongoose) this.filters.mongoose = true;
if(answers.auth) this.filters.auth = true;
if(answers.oauth) {
if(answers.oauth.length) this.filters.oauth = true;
answers.oauth.forEach(function(oauthStrategy) {
this.filters[oauthStrategy] = true;
}.bind(this));
Expand Down
20 changes: 10 additions & 10 deletions app/templates/client/app/account(auth)/login/login(css).css
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
.btn-facebook {
<% if (filters.oauth) { %><% if (filters.facebookAuth) { %>.btn-facebook {
color: #fff;
background-color: #3B5998;
border-color: #133783;
}

<% } if (filters.twitterAuth) { %>
.btn-twitter {
color: #fff;
background-color: #2daddc;
border-color: #0271bf;
}

.btn-github {
color: #fff;
background-color: #fafafa;
border-color: #ccc;
}

<% } if (filters.googleAuth) { %>
.btn-google-plus {
color: #fff;
background-color: #dd4b39;
border-color: #c53727;
}
}
<% } %>
.btn-github {
color: #fff;
background-color: #fafafa;
border-color: #ccc;
}<% } %>
5 changes: 2 additions & 3 deletions app/templates/client/app/account(auth)/login/login(html).html
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@ <h1>Login</h1>
Register
</a>
</div>

<% if(filters.facebookAuth || filters.twitterAuth || filters.googleAuth) {%>
<% if(filters.oauth) {%>
<hr>
<div><% if(filters.facebookAuth) {%>
<a class="btn btn-facebook" href="" ng-click="loginOauth('facebook')">
Expand All @@ -55,4 +54,4 @@ <h1>Login</h1>
</div>
</div>
<hr>
</div>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@ div(ng-include='"components/navbar/navbar.html"')
= ' '
a.btn.btn-default.btn-lg.btn-register(href='/signup')
| Register

<% if(filters.facebookAuth || filters.twitterAuth || filters.googleAuth) {%>
<% if(filters.oauth) {%>
hr

div<% if(filters.facebookAuth) {%>
Expand Down
36 changes: 14 additions & 22 deletions app/templates/client/app/account(auth)/login/login(less).less
Original file line number Diff line number Diff line change
@@ -1,38 +1,30 @@
<% if(filters.bootstrap) { %>
// Colors
<% if(filters.bootstrap) { %>// Colors
// --------------------------------------------------

@btnText: #fff;
@btnTextAlt: #000;

@btnTextAlt: #000;<% if (filters.oauth) { %>
<% if (filters.facebookAuth) { %>
@btnFacebookBackground: #3B5998;
@btnFacebookBackgroundHighlight: #133783;

@btnFacebookBackgroundHighlight: #133783;<% } if (filters.twitterAuth) { %>
@btnTwitterBackground: #2daddc;
@btnTwitterBackgroundHighlight: #0271bf;

@btnTwitterBackgroundHighlight: #0271bf;<% } if (filters.googleAuth) { %>
@btnGooglePlusBackground: #dd4b39;
@btnGooglePlusBackgroundHighlight: #c53727;<% } %>
@btnGithubBackground: #fafafa;
@btnGithubBackgroundHighlight: #ccc;

@btnGooglePlusBackground: #dd4b39;
@btnGooglePlusBackgroundHighlight: #c53727;


// Social buttons
// --------------------------------------------------

<% if (filters.facebookAuth) { %>
.btn-facebook {
.button-variant(@btnText; @btnFacebookBackgroundHighlight; @btnFacebookBackgroundHighlight);
}

}<% } if (filters.twitterAuth) { %>
.btn-twitter {
.button-variant(@btnText; @btnTwitterBackground; @btnTwitterBackgroundHighlight);
}

.btn-github {
.button-variant(@btnTextAlt; @btnGithubBackground; @btnGithubBackgroundHighlight);
}

}<% } if (filters.googleAuth) { %>
.btn-google-plus {
.button-variant(@btnText; @btnGooglePlusBackground; @btnGooglePlusBackgroundHighlight);
}<% } %>
}<% } %>
.btn-github {
.button-variant(@btnTextAlt; @btnGithubBackground; @btnGithubBackgroundHighlight);
}<% } %><% } %>
36 changes: 14 additions & 22 deletions app/templates/client/app/account(auth)/login/login(sass).scss
Original file line number Diff line number Diff line change
@@ -1,38 +1,30 @@
<% if(filters.bootstrap) { %>
// Colors
<% if(filters.bootstrap) { %>// Colors
// --------------------------------------------------

$btnText: #fff;
$btnTextAlt: #000;

$btnTextAlt: #000;<% if (filters.oauth) { %>
<% if (filters.facebookAuth) { %>
$btnFacebookBackground: #3B5998;
$btnFacebookBackgroundHighlight: #133783;

$btnFacebookBackgroundHighlight: #133783;<% } if (filters.twitterAuth) { %>
$btnTwitterBackground: #2daddc;
$btnTwitterBackgroundHighlight: #0271bf;

$btnTwitterBackgroundHighlight: #0271bf;<% } if (filters.googleAuth) { %>
$btnGooglePlusBackground: #dd4b39;
$btnGooglePlusBackgroundHighlight: #c53727;<% } %>
$btnGithubBackground: #fafafa;
$btnGithubBackgroundHighlight: #ccc;

$btnGooglePlusBackground: #dd4b39;
$btnGooglePlusBackgroundHighlight: #c53727;


// Social buttons
// --------------------------------------------------

<% if (filters.facebookAuth) { %>
.btn-facebook {
@include button-variant($btnText, $btnFacebookBackgroundHighlight, $btnFacebookBackgroundHighlight);
}

}<% } if (filters.twitterAuth) { %>
.btn-twitter {
@include button-variant($btnText, $btnTwitterBackground, $btnTwitterBackgroundHighlight);
}

.btn-github {
@include button-variant($btnTextAlt, $btnGithubBackground, $btnGithubBackgroundHighlight);
}

}<% } if (filters.googleAuth) { %>
.btn-google-plus {
@include button-variant($btnText, $btnGooglePlusBackground, $btnGooglePlusBackgroundHighlight);
}<% } %>
}<% } %>
.btn-github {
@include button-variant($btnTextAlt, $btnGithubBackground, $btnGithubBackgroundHighlight);
}<% } %><% } %>
20 changes: 10 additions & 10 deletions app/templates/client/app/account(auth)/login/login(stylus).styl
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
// Social buttons
<% if (filters.oauth) { %>// Social buttons
// --------------------------------------------------

<% if (filters.facebookAuth) { %>
.btn-facebook
color: #fff;
background-color: #3B5998;
border-color: #133783;

<% } if (filters.twitterAuth) { %>
.btn-twitter
color: #fff;
background-color: #2daddc;
border-color: #0271bf;

.btn-github
color: #fff;
background-color: #fafafa;
border-color: #ccc;

<% } if (filters.googleAuth) { %>
.btn-google-plus
color: #fff;
background-color: #dd4b39;
border-color: #c53727;
border-color: #c53727;
<% } %>
.btn-github
color: #fff;
background-color: #fafafa;
border-color: #ccc;<% } %>
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict'

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

.catch (err) ->
$scope.errors.other = err.message

<% if(filters.oauth) {%>
$scope.loginOauth = (provider) ->
$window.location.href = '/auth/' + provider
$window.location.href = '/auth/' + provider<% } %>
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict';

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

Expand All @@ -22,8 +22,8 @@ angular.module('<%= scriptAppName %>')
});
}
};

<% if(filters.oauth) {%>
$scope.loginOauth = function(provider) {
$window.location.href = '/auth/' + provider;
};
};<% } %>
});
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,7 @@ <h1>Sign up</h1>
Login
</a>
</div>

<% if(filters.facebookAuth || filters.twitterAuth || filters.googleAuth) {%>
<% if(filters.oauth) {%>
<hr>
<div><% if(filters.facebookAuth) {%>
<a class="btn btn-facebook" href="" ng-click="loginOauth('facebook')">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,7 @@ div(ng-include='"components/navbar/navbar.html"')
a.btn.btn-default.btn-lg.btn-register(href='/login')
| Login


<% if(filters.facebookAuth || filters.twitterAuth || filters.googleAuth) {%>
<% if(filters.oauth) {%>
hr

div<% if(filters.facebookAuth) {%>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict'

angular.module '<%= scriptAppName %>'
.controller 'SignupCtrl', ($scope, Auth, $location, $window) ->
.controller 'SignupCtrl', ($scope, Auth, $location<% if(filters.oauth) {%>, $window<% } %>) ->
$scope.user = {}
$scope.errors = {}
$scope.register = (form) ->
Expand All @@ -25,6 +25,6 @@ angular.module '<%= scriptAppName %>'
angular.forEach err.errors, (error, field) ->
form[field].$setValidity 'mongoose', false
$scope.errors[field] = error.message

<% if(filters.oauth) {%>
$scope.loginOauth = (provider) ->
$window.location.href = '/auth/' + provider
$window.location.href = '/auth/' + provider<% } %>
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict';

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

Expand Down Expand Up @@ -30,8 +30,8 @@ angular.module('<%= scriptAppName %>')
});
}
};

<% if(filters.oauth) {%>
$scope.loginOauth = function(provider) {
$window.location.href = '/auth/' + provider;
};
};<% } %>
});
27 changes: 12 additions & 15 deletions app/templates/server/api/user(auth)/user.model.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@

var mongoose = require('mongoose');
var Schema = mongoose.Schema;
var crypto = require('crypto');

var authTypes = ['github', 'twitter', 'facebook', 'google'];
var crypto = require('crypto');<% if(filters.oauth) { %>
var authTypes = ['github', 'twitter', 'facebook', 'google'];<% } %>

var UserSchema = new Schema({
name: String,
Expand All @@ -15,11 +14,11 @@ var UserSchema = new Schema({
},
hashedPassword: String,
provider: String,
salt: String,
facebook: {},
twitter: {},
github: {},
google: {}
salt: String<% if (filters.oauth) { %>,<% if (filters.facebookAuth) { %>
facebook: {},<% } %><% if (filters.twitterAuth) { %>
twitter: {},<% } %><% if (filters.googleAuth) { %>
google: {},<% } %>
github: {}<% } %>
});

/**
Expand Down Expand Up @@ -63,18 +62,16 @@ UserSchema
// Validate empty email
UserSchema
.path('email')
.validate(function(email) {
// if you are authenticating by any of the oauth strategies, don't validate
if (authTypes.indexOf(this.provider) !== -1) return true;
.validate(function(email) {<% if (filters.oauth) { %>
if (authTypes.indexOf(this.provider) !== -1) return true;<% } %>
return email.length;
}, 'Email cannot be blank');

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

Expand Down Expand Up @@ -104,7 +101,7 @@ UserSchema
.pre('save', function(next) {
if (!this.isNew) return next();

if (!validatePresenceOf(this.hashedPassword) && authTypes.indexOf(this.provider) === -1)
if (!validatePresenceOf(this.hashedPassword)<% if (filters.oauth) { %> && authTypes.indexOf(this.provider) === -1<% } %>)
next(new Error('Invalid password'));
else
next();
Expand Down
Loading