diff --git a/app/index.js b/app/index.js index 9f943316c..bb4bc4023 100644 --- a/app/index.js +++ b/app/index.js @@ -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)); diff --git a/app/templates/client/app/account(auth)/login/login(css).css b/app/templates/client/app/account(auth)/login/login(css).css index eb4983fca..7c865ffc6 100644 --- a/app/templates/client/app/account(auth)/login/login(css).css +++ b/app/templates/client/app/account(auth)/login/login(css).css @@ -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; -} \ No newline at end of file +} +<% } %> +.btn-github { + color: #fff; + background-color: #fafafa; + border-color: #ccc; +}<% } %> diff --git a/app/templates/client/app/account(auth)/login/login(html).html b/app/templates/client/app/account(auth)/login/login(html).html index d0bcc72a1..483300478 100644 --- a/app/templates/client/app/account(auth)/login/login(html).html +++ b/app/templates/client/app/account(auth)/login/login(html).html @@ -37,8 +37,7 @@

Login

Register - - <% if(filters.facebookAuth || filters.twitterAuth || filters.googleAuth) {%> +<% if(filters.oauth) {%>
<% if(filters.facebookAuth) {%> @@ -55,4 +54,4 @@

Login


- \ No newline at end of file + diff --git a/app/templates/client/app/account(auth)/login/login(jade).jade b/app/templates/client/app/account(auth)/login/login(jade).jade index 529282deb..4b13c0b13 100644 --- a/app/templates/client/app/account(auth)/login/login(jade).jade +++ b/app/templates/client/app/account(auth)/login/login(jade).jade @@ -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) {%> diff --git a/app/templates/client/app/account(auth)/login/login(less).less b/app/templates/client/app/account(auth)/login/login(less).less index fc9e26556..bd01a056e 100644 --- a/app/templates/client/app/account(auth)/login/login(less).less +++ b/app/templates/client/app/account(auth)/login/login(less).less @@ -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); -}<% } %> \ No newline at end of file +}<% } %> +.btn-github { + .button-variant(@btnTextAlt; @btnGithubBackground; @btnGithubBackgroundHighlight); +}<% } %><% } %> diff --git a/app/templates/client/app/account(auth)/login/login(sass).scss b/app/templates/client/app/account(auth)/login/login(sass).scss index bbfca2eb7..eb214a8ca 100644 --- a/app/templates/client/app/account(auth)/login/login(sass).scss +++ b/app/templates/client/app/account(auth)/login/login(sass).scss @@ -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); -}<% } %> \ No newline at end of file +}<% } %> +.btn-github { + @include button-variant($btnTextAlt, $btnGithubBackground, $btnGithubBackgroundHighlight); +}<% } %><% } %> diff --git a/app/templates/client/app/account(auth)/login/login(stylus).styl b/app/templates/client/app/account(auth)/login/login(stylus).styl index 78389dd1f..3dc78ee9d 100644 --- a/app/templates/client/app/account(auth)/login/login(stylus).styl +++ b/app/templates/client/app/account(auth)/login/login(stylus).styl @@ -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; \ No newline at end of file + border-color: #c53727; +<% } %> +.btn-github + color: #fff; + background-color: #fafafa; + border-color: #ccc;<% } %> diff --git a/app/templates/client/app/account(auth)/login/login.controller(coffee).coffee b/app/templates/client/app/account(auth)/login/login.controller(coffee).coffee index a3e4d61b1..3f90c25d7 100644 --- a/app/templates/client/app/account(auth)/login/login.controller(coffee).coffee +++ b/app/templates/client/app/account(auth)/login/login.controller(coffee).coffee @@ -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) -> @@ -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 \ No newline at end of file + $window.location.href = '/auth/' + provider<% } %> diff --git a/app/templates/client/app/account(auth)/login/login.controller(js).js b/app/templates/client/app/account(auth)/login/login.controller(js).js index 554311cbb..7b13da384 100644 --- a/app/templates/client/app/account(auth)/login/login.controller(js).js +++ b/app/templates/client/app/account(auth)/login/login.controller(js).js @@ -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 = {}; @@ -22,8 +22,8 @@ angular.module('<%= scriptAppName %>') }); } }; - +<% if(filters.oauth) {%> $scope.loginOauth = function(provider) { $window.location.href = '/auth/' + provider; - }; + };<% } %> }); 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 6e344f082..59faed568 100644 --- a/app/templates/client/app/account(auth)/signup/signup(html).html +++ b/app/templates/client/app/account(auth)/signup/signup(html).html @@ -62,8 +62,7 @@

Sign up

Login
- - <% if(filters.facebookAuth || filters.twitterAuth || filters.googleAuth) {%> +<% if(filters.oauth) {%>
<% if(filters.facebookAuth) {%> diff --git a/app/templates/client/app/account(auth)/signup/signup(jade).jade b/app/templates/client/app/account(auth)/signup/signup(jade).jade index 02bf47706..43815a21c 100644 --- a/app/templates/client/app/account(auth)/signup/signup(jade).jade +++ b/app/templates/client/app/account(auth)/signup/signup(jade).jade @@ -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) {%> diff --git a/app/templates/client/app/account(auth)/signup/signup.controller(coffee).coffee b/app/templates/client/app/account(auth)/signup/signup.controller(coffee).coffee index b10b9c3fd..1b9c9696f 100644 --- a/app/templates/client/app/account(auth)/signup/signup.controller(coffee).coffee +++ b/app/templates/client/app/account(auth)/signup/signup.controller(coffee).coffee @@ -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) -> @@ -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<% } %> diff --git a/app/templates/client/app/account(auth)/signup/signup.controller(js).js b/app/templates/client/app/account(auth)/signup/signup.controller(js).js index 0377daa44..7d6ba3d38 100644 --- a/app/templates/client/app/account(auth)/signup/signup.controller(js).js +++ b/app/templates/client/app/account(auth)/signup/signup.controller(js).js @@ -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 = {}; @@ -30,8 +30,8 @@ angular.module('<%= scriptAppName %>') }); } }; - +<% if(filters.oauth) {%> $scope.loginOauth = function(provider) { $window.location.href = '/auth/' + provider; - }; + };<% } %> }); diff --git a/app/templates/server/api/user(auth)/user.model.js b/app/templates/server/api/user(auth)/user.model.js index 009f28947..cc8d59263 100644 --- a/app/templates/server/api/user(auth)/user.model.js +++ b/app/templates/server/api/user(auth)/user.model.js @@ -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, @@ -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: {}<% } %> }); /** @@ -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'); @@ -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(); diff --git a/app/templates/server/config/_local.env.js b/app/templates/server/config/_local.env.js index 145479041..9e315944b 100644 --- a/app/templates/server/config/_local.env.js +++ b/app/templates/server/config/_local.env.js @@ -6,13 +6,13 @@ // This file should not be tracked by git. module.exports = { - SESSION_SECRET: "<%= _.slugify(appname) + '-secret' %>", + SESSION_SECRET: "<%= _.slugify(appname) + '-secret' %>",<% if (filters.facebookAuth) { %> FACEBOOK_ID: "app-id", - FACEBOOK_SECRET: "secret", + FACEBOOK_SECRET: "secret",<% } if (filters.twitterAuth) { %> TWITTER_ID: "app-id", - TWITTER_SECRET: "secret", + TWITTER_SECRET: "secret",<% } if (filters.googleAuth) { %> GOOGLE_ID: "app-id", - GOOGLE_SECRET: "secret", + GOOGLE_SECRET: "secret",<% } %> // Control debug level for modules using visionmedia/debug - // DEBUG: "" -}; \ No newline at end of file + DEBUG: "" +};