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

Commit 3dcf45c

Browse files
committed
Added github signin/signup to the list of signups/signi's
1 parent ba0a6a0 commit 3dcf45c

File tree

8 files changed

+142
-76
lines changed

8 files changed

+142
-76
lines changed

config/env/development.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,10 @@ module.exports = {
2424
clientID: process.env.LINKEDIN_ID || 'APP_ID',
2525
clientSecret: process.env.LINKEDIN_SECRET || 'APP_SECRET',
2626
callbackURL: 'http://localhost:3000/auth/linkedin/callback'
27-
}
28-
};
27+
},
28+
github: {
29+
clientID: process.env.GITHUB_ID || 'APP_ID',
30+
clientSecret: process.env.GITHUB_SECRET || 'APP_SECRET',
31+
callbackURL: 'http://localhost:3000/auth/github/callback'
32+
}
33+
};

config/env/production.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,5 +39,10 @@ module.exports = {
3939
clientID: process.env.LINKEDIN_ID || 'APP_ID',
4040
clientSecret: process.env.LINKEDIN_SECRET || 'APP_SECRET',
4141
callbackURL: 'http://localhost:3000/auth/linkedin/callback'
42-
}
43-
};
42+
},
43+
github: {
44+
clientID: process.env.GITHUB_ID || 'APP_ID',
45+
clientSecret: process.env.GITHUB_SECRET || 'APP_SECRET',
46+
callbackURL: 'http://localhost:3000/auth/github/callback'
47+
}
48+
};

config/env/test.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,10 @@ module.exports = {
2525
clientID: process.env.LINKEDIN_ID || 'APP_ID',
2626
clientSecret: process.env.LINKEDIN_SECRET || 'APP_SECRET',
2727
callbackURL: 'http://localhost:3000/auth/linkedin/callback'
28-
}
29-
};
28+
},
29+
github: {
30+
clientID: process.env.GITHUB_ID || 'APP_ID',
31+
clientSecret: process.env.GITHUB_SECRET || 'APP_SECRET',
32+
callbackURL: 'http://localhost:3000/auth/github/callback'
33+
}
34+
};

config/strategies/github.js

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
'use strict';
2+
3+
/**
4+
* Module dependencies.
5+
*/
6+
var passport = require('passport'),
7+
url = require('url'),
8+
GithubStrategy = require('passport-github').Strategy,
9+
config = require('../config'),
10+
users = require('../../app/controllers/users');
11+
12+
module.exports = function() {
13+
// Use github strategy
14+
passport.use(new GithubStrategy({
15+
clientID: config.github.clientID,
16+
clientSecret: config.github.clientSecret,
17+
callbackURL: config.github.callbackURL,
18+
passReqToCallback: true
19+
},
20+
function(req, accessToken, refreshToken, profile, done) {
21+
// Set the provider data and include tokens
22+
var providerData = profile._json;
23+
providerData.accessToken = accessToken;
24+
providerData.refreshToken = refreshToken;
25+
26+
// Create the user OAuth profile
27+
var providerUserProfile = {
28+
firstName: profile.name.givenName,
29+
lastName: profile.name.familyName,
30+
displayName: profile.displayName,
31+
email: profile.emails[0].value,
32+
username: profile.username,
33+
provider: 'github',
34+
providerIdentifierField: 'id',
35+
providerData: providerData
36+
};
37+
38+
// Save the user OAuth profile
39+
users.saveOAuthUserProfile(req, providerUserProfile, done);
40+
}
41+
));
42+
};

package.json

Lines changed: 69 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -1,69 +1,70 @@
11
{
2-
"name": "meanjs",
3-
"description": "Full-Stack JavaScript with MongoDB, Express, AngularJS, and Node.js.",
4-
"version": "0.3.1",
5-
"private": false,
6-
"author": "https://github.com/meanjs/mean/graphs/contributors",
7-
"repository": {
8-
"type": "git",
9-
"url": "https://github.com/meanjs/mean.git"
10-
},
11-
"engines": {
12-
"node": "0.10.x",
13-
"npm": "1.4.x"
14-
},
15-
"scripts": {
16-
"start": "grunt",
17-
"test": "grunt test",
18-
"postinstall": "bower install --config.interactive=false"
19-
},
20-
"dependencies": {
21-
"express": "~4.2.0",
22-
"express-session": "~1.1.0",
23-
"body-parser": "~1.2.0",
24-
"cookie-parser": "~1.1.0",
25-
"compression": "~1.0.1",
26-
"method-override": "~1.0.0",
27-
"morgan": "~1.1.0",
28-
"connect-mongo": "~0.4.0",
29-
"connect-flash": "~0.1.1",
30-
"helmet": "~0.2.1",
31-
"consolidate": "~0.10.0",
32-
"swig": "~1.3.2",
33-
"mongoose": "~3.8.8",
34-
"passport": "~0.2.0",
35-
"passport-local": "~1.0.0",
36-
"passport-facebook": "~1.0.2",
37-
"passport-twitter": "~1.0.2",
38-
"passport-linkedin": "~0.1.3",
39-
"passport-google-oauth": "~0.1.5",
40-
"lodash": "~2.4.1",
41-
"forever": "~0.11.0",
42-
"bower": "~1.3.1",
43-
"grunt-cli": "~0.1.13",
44-
"glob": "~3.2.9"
45-
},
46-
"devDependencies": {
47-
"supertest": "~0.12.1",
48-
"should": "~3.3.1",
49-
"grunt-env": "~0.4.1",
50-
"grunt-node-inspector": "~0.1.3",
51-
"grunt-contrib-watch": "~0.6.1",
52-
"grunt-contrib-jshint": "~0.10.0",
53-
"grunt-contrib-csslint": "^0.2.0",
54-
"grunt-ngmin": "0.0.3",
55-
"grunt-contrib-uglify": "~0.4.0",
56-
"grunt-contrib-cssmin": "~0.9.0",
57-
"grunt-nodemon": "~0.2.1",
58-
"grunt-concurrent": "~0.5.0",
59-
"grunt-mocha-test": "~0.10.0",
60-
"grunt-karma": "~0.8.2",
61-
"load-grunt-tasks": "~0.4.0",
62-
"karma": "~0.12.0",
63-
"karma-jasmine": "~0.2.1",
64-
"karma-coverage": "~0.2.0",
65-
"karma-chrome-launcher": "~0.1.2",
66-
"karma-firefox-launcher": "~0.1.3",
67-
"karma-phantomjs-launcher": "~0.1.2"
68-
}
69-
}
2+
"name": "meanjs",
3+
"description": "Full-Stack JavaScript with MongoDB, Express, AngularJS, and Node.js.",
4+
"version": "0.3.1",
5+
"private": false,
6+
"author": "https://github.com/meanjs/mean/graphs/contributors",
7+
"repository": {
8+
"type": "git",
9+
"url": "https://github.com/meanjs/mean.git"
10+
},
11+
"engines": {
12+
"node": "0.10.x",
13+
"npm": "1.4.x"
14+
},
15+
"scripts": {
16+
"start": "grunt",
17+
"test": "grunt test",
18+
"postinstall": "bower install --config.interactive=false"
19+
},
20+
"dependencies": {
21+
"body-parser": "~1.2.0",
22+
"bower": "~1.3.1",
23+
"compression": "~1.0.1",
24+
"connect-flash": "~0.1.1",
25+
"connect-mongo": "~0.4.0",
26+
"consolidate": "~0.10.0",
27+
"cookie-parser": "~1.1.0",
28+
"express": "~4.2.0",
29+
"express-session": "~1.1.0",
30+
"forever": "~0.11.0",
31+
"glob": "~3.2.9",
32+
"grunt-cli": "~0.1.13",
33+
"helmet": "~0.2.1",
34+
"lodash": "~2.4.1",
35+
"method-override": "~1.0.0",
36+
"mongoose": "~3.8.8",
37+
"morgan": "~1.1.0",
38+
"passport": "~0.2.0",
39+
"passport-facebook": "~1.0.2",
40+
"passport-github": "^0.1.5",
41+
"passport-google-oauth": "~0.1.5",
42+
"passport-linkedin": "~0.1.3",
43+
"passport-local": "~1.0.0",
44+
"passport-twitter": "~1.0.2",
45+
"swig": "~1.3.2"
46+
},
47+
"devDependencies": {
48+
"supertest": "~0.12.1",
49+
"should": "~3.3.1",
50+
"grunt-env": "~0.4.1",
51+
"grunt-node-inspector": "~0.1.3",
52+
"grunt-contrib-watch": "~0.6.1",
53+
"grunt-contrib-jshint": "~0.10.0",
54+
"grunt-contrib-csslint": "^0.2.0",
55+
"grunt-ngmin": "0.0.3",
56+
"grunt-contrib-uglify": "~0.4.0",
57+
"grunt-contrib-cssmin": "~0.9.0",
58+
"grunt-nodemon": "~0.2.1",
59+
"grunt-concurrent": "~0.5.0",
60+
"grunt-mocha-test": "~0.10.0",
61+
"grunt-karma": "~0.8.2",
62+
"load-grunt-tasks": "~0.4.0",
63+
"karma": "~0.12.0",
64+
"karma-jasmine": "~0.2.1",
65+
"karma-coverage": "~0.2.0",
66+
"karma-chrome-launcher": "~0.1.2",
67+
"karma-firefox-launcher": "~0.1.3",
68+
"karma-phantomjs-launcher": "~0.1.2"
69+
}
70+
}
9.58 KB
Loading

public/modules/users/views/signin.client.view.html

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ <h3 class="col-md-12 text-center">Sign in using your social accounts</h3>
1313
<a href="/auth/linkedin" class="undecorated-link">
1414
<img src="/modules/users/img/buttons/linkedin.png">
1515
</a>
16+
<a href="/auth/github" class="undecorated-link">
17+
<img src="/modules/users/img/buttons/github.png">
18+
</a>
19+
1620
</div>
1721
<h3 class="col-md-12 text-center">Or with your account</h3>
1822
<div class="col-xs-offset-2 col-xs-8 col-md-offset-5 col-md-2">
@@ -36,4 +40,4 @@ <h3 class="col-md-12 text-center">Or with your account</h3>
3640
</fieldset>
3741
</form>
3842
</div>
39-
</section>
43+
</section>

public/modules/users/views/signup.client.view.html

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ <h3 class="col-md-12 text-center">Sign up using your social accounts</h3>
1313
<a href="/auth/linkedin" class="undecorated-link">
1414
<img src="/modules/users/img/buttons/linkedin.png">
1515
</a>
16+
<a href="/auth/github" class="undecorated-link">
17+
<img src="/modules/users/img/buttons/github.png">
18+
</a>
19+
1620
</div>
1721
<h3 class="col-md-12 text-center">Or with your email</h3>
1822
<div class="col-xs-offset-2 col-xs-8 col-md-offset-5 col-md-2">
@@ -48,4 +52,4 @@ <h3 class="col-md-12 text-center">Or with your email</h3>
4852
</fieldset>
4953
</form>
5054
</div>
51-
</section>
55+
</section>

0 commit comments

Comments
 (0)