Skip to content
This repository has been archived by the owner on Aug 30, 2021. It is now read-only.

Commit

Permalink
Added github signin/signup to the list of signups/signi's
Browse files Browse the repository at this point in the history
  • Loading branch information
anooprh committed Aug 1, 2014
1 parent ba0a6a0 commit 3dcf45c
Show file tree
Hide file tree
Showing 8 changed files with 142 additions and 76 deletions.
9 changes: 7 additions & 2 deletions config/env/development.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,10 @@ module.exports = {
clientID: process.env.LINKEDIN_ID || 'APP_ID',
clientSecret: process.env.LINKEDIN_SECRET || 'APP_SECRET',
callbackURL: 'http://localhost:3000/auth/linkedin/callback'
}
};
},
github: {
clientID: process.env.GITHUB_ID || 'APP_ID',
clientSecret: process.env.GITHUB_SECRET || 'APP_SECRET',
callbackURL: 'http://localhost:3000/auth/github/callback'
}
};
9 changes: 7 additions & 2 deletions config/env/production.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,10 @@ module.exports = {
clientID: process.env.LINKEDIN_ID || 'APP_ID',
clientSecret: process.env.LINKEDIN_SECRET || 'APP_SECRET',
callbackURL: 'http://localhost:3000/auth/linkedin/callback'
}
};
},
github: {
clientID: process.env.GITHUB_ID || 'APP_ID',
clientSecret: process.env.GITHUB_SECRET || 'APP_SECRET',
callbackURL: 'http://localhost:3000/auth/github/callback'
}
};
9 changes: 7 additions & 2 deletions config/env/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,10 @@ module.exports = {
clientID: process.env.LINKEDIN_ID || 'APP_ID',
clientSecret: process.env.LINKEDIN_SECRET || 'APP_SECRET',
callbackURL: 'http://localhost:3000/auth/linkedin/callback'
}
};
},
github: {
clientID: process.env.GITHUB_ID || 'APP_ID',
clientSecret: process.env.GITHUB_SECRET || 'APP_SECRET',
callbackURL: 'http://localhost:3000/auth/github/callback'
}
};
42 changes: 42 additions & 0 deletions config/strategies/github.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
'use strict';

/**
* Module dependencies.
*/
var passport = require('passport'),
url = require('url'),
GithubStrategy = require('passport-github').Strategy,
config = require('../config'),
users = require('../../app/controllers/users');

module.exports = function() {
// Use github strategy
passport.use(new GithubStrategy({
clientID: config.github.clientID,
clientSecret: config.github.clientSecret,
callbackURL: config.github.callbackURL,
passReqToCallback: true
},
function(req, accessToken, refreshToken, profile, done) {
// Set the provider data and include tokens
var providerData = profile._json;
providerData.accessToken = accessToken;
providerData.refreshToken = refreshToken;

// Create the user OAuth profile
var providerUserProfile = {
firstName: profile.name.givenName,
lastName: profile.name.familyName,
displayName: profile.displayName,
email: profile.emails[0].value,
username: profile.username,
provider: 'github',
providerIdentifierField: 'id',
providerData: providerData
};

// Save the user OAuth profile
users.saveOAuthUserProfile(req, providerUserProfile, done);
}
));
};
137 changes: 69 additions & 68 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,69 +1,70 @@
{
"name": "meanjs",
"description": "Full-Stack JavaScript with MongoDB, Express, AngularJS, and Node.js.",
"version": "0.3.1",
"private": false,
"author": "https://github.com/meanjs/mean/graphs/contributors",
"repository": {
"type": "git",
"url": "https://github.com/meanjs/mean.git"
},
"engines": {
"node": "0.10.x",
"npm": "1.4.x"
},
"scripts": {
"start": "grunt",
"test": "grunt test",
"postinstall": "bower install --config.interactive=false"
},
"dependencies": {
"express": "~4.2.0",
"express-session": "~1.1.0",
"body-parser": "~1.2.0",
"cookie-parser": "~1.1.0",
"compression": "~1.0.1",
"method-override": "~1.0.0",
"morgan": "~1.1.0",
"connect-mongo": "~0.4.0",
"connect-flash": "~0.1.1",
"helmet": "~0.2.1",
"consolidate": "~0.10.0",
"swig": "~1.3.2",
"mongoose": "~3.8.8",
"passport": "~0.2.0",
"passport-local": "~1.0.0",
"passport-facebook": "~1.0.2",
"passport-twitter": "~1.0.2",
"passport-linkedin": "~0.1.3",
"passport-google-oauth": "~0.1.5",
"lodash": "~2.4.1",
"forever": "~0.11.0",
"bower": "~1.3.1",
"grunt-cli": "~0.1.13",
"glob": "~3.2.9"
},
"devDependencies": {
"supertest": "~0.12.1",
"should": "~3.3.1",
"grunt-env": "~0.4.1",
"grunt-node-inspector": "~0.1.3",
"grunt-contrib-watch": "~0.6.1",
"grunt-contrib-jshint": "~0.10.0",
"grunt-contrib-csslint": "^0.2.0",
"grunt-ngmin": "0.0.3",
"grunt-contrib-uglify": "~0.4.0",
"grunt-contrib-cssmin": "~0.9.0",
"grunt-nodemon": "~0.2.1",
"grunt-concurrent": "~0.5.0",
"grunt-mocha-test": "~0.10.0",
"grunt-karma": "~0.8.2",
"load-grunt-tasks": "~0.4.0",
"karma": "~0.12.0",
"karma-jasmine": "~0.2.1",
"karma-coverage": "~0.2.0",
"karma-chrome-launcher": "~0.1.2",
"karma-firefox-launcher": "~0.1.3",
"karma-phantomjs-launcher": "~0.1.2"
}
}
"name": "meanjs",
"description": "Full-Stack JavaScript with MongoDB, Express, AngularJS, and Node.js.",
"version": "0.3.1",
"private": false,
"author": "https://github.com/meanjs/mean/graphs/contributors",
"repository": {
"type": "git",
"url": "https://github.com/meanjs/mean.git"
},
"engines": {
"node": "0.10.x",
"npm": "1.4.x"
},
"scripts": {
"start": "grunt",
"test": "grunt test",
"postinstall": "bower install --config.interactive=false"
},
"dependencies": {
"body-parser": "~1.2.0",
"bower": "~1.3.1",
"compression": "~1.0.1",
"connect-flash": "~0.1.1",
"connect-mongo": "~0.4.0",
"consolidate": "~0.10.0",
"cookie-parser": "~1.1.0",
"express": "~4.2.0",
"express-session": "~1.1.0",
"forever": "~0.11.0",
"glob": "~3.2.9",
"grunt-cli": "~0.1.13",
"helmet": "~0.2.1",
"lodash": "~2.4.1",
"method-override": "~1.0.0",
"mongoose": "~3.8.8",
"morgan": "~1.1.0",
"passport": "~0.2.0",
"passport-facebook": "~1.0.2",
"passport-github": "^0.1.5",
"passport-google-oauth": "~0.1.5",
"passport-linkedin": "~0.1.3",
"passport-local": "~1.0.0",
"passport-twitter": "~1.0.2",
"swig": "~1.3.2"
},
"devDependencies": {
"supertest": "~0.12.1",
"should": "~3.3.1",
"grunt-env": "~0.4.1",
"grunt-node-inspector": "~0.1.3",
"grunt-contrib-watch": "~0.6.1",
"grunt-contrib-jshint": "~0.10.0",
"grunt-contrib-csslint": "^0.2.0",
"grunt-ngmin": "0.0.3",
"grunt-contrib-uglify": "~0.4.0",
"grunt-contrib-cssmin": "~0.9.0",
"grunt-nodemon": "~0.2.1",
"grunt-concurrent": "~0.5.0",
"grunt-mocha-test": "~0.10.0",
"grunt-karma": "~0.8.2",
"load-grunt-tasks": "~0.4.0",
"karma": "~0.12.0",
"karma-jasmine": "~0.2.1",
"karma-coverage": "~0.2.0",
"karma-chrome-launcher": "~0.1.2",
"karma-firefox-launcher": "~0.1.3",
"karma-phantomjs-launcher": "~0.1.2"
}
}
Binary file added public/modules/users/img/buttons/github.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 5 additions & 1 deletion public/modules/users/views/signin.client.view.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ <h3 class="col-md-12 text-center">Sign in using your social accounts</h3>
<a href="/auth/linkedin" class="undecorated-link">
<img src="/modules/users/img/buttons/linkedin.png">
</a>
<a href="/auth/github" class="undecorated-link">
<img src="/modules/users/img/buttons/github.png">
</a>

</div>
<h3 class="col-md-12 text-center">Or with your account</h3>
<div class="col-xs-offset-2 col-xs-8 col-md-offset-5 col-md-2">
Expand All @@ -36,4 +40,4 @@ <h3 class="col-md-12 text-center">Or with your account</h3>
</fieldset>
</form>
</div>
</section>
</section>
6 changes: 5 additions & 1 deletion public/modules/users/views/signup.client.view.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ <h3 class="col-md-12 text-center">Sign up using your social accounts</h3>
<a href="/auth/linkedin" class="undecorated-link">
<img src="/modules/users/img/buttons/linkedin.png">
</a>
<a href="/auth/github" class="undecorated-link">
<img src="/modules/users/img/buttons/github.png">
</a>

</div>
<h3 class="col-md-12 text-center">Or with your email</h3>
<div class="col-xs-offset-2 col-xs-8 col-md-offset-5 col-md-2">
Expand Down Expand Up @@ -48,4 +52,4 @@ <h3 class="col-md-12 text-center">Or with your email</h3>
</fieldset>
</form>
</div>
</section>
</section>

0 comments on commit 3dcf45c

Please sign in to comment.