Skip to content

Commit

Permalink
Merge 06205ad into af8bad0
Browse files Browse the repository at this point in the history
  • Loading branch information
Subastkar committed Sep 26, 2014
2 parents af8bad0 + 06205ad commit 446c66a
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 25 deletions.
41 changes: 17 additions & 24 deletions examples/login/app.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
var express = require('express')
, passport = require('passport')
, logger = require('morgan')
, cookieParser = require('cookie-parser')
, session = require('express-session')
, bodyParser = require('body-parser')
, util = require('util')
, GitHubStrategy = require('passport-github').Strategy;

Expand Down Expand Up @@ -46,26 +50,20 @@ passport.use(new GitHubStrategy({
));




var app = express.createServer();
var app = express();

// configure Express
app.configure(function() {
app.set('views', __dirname + '/views');
app.set('view engine', 'ejs');
app.use(express.logger());
app.use(express.cookieParser());
app.use(express.bodyParser());
app.use(express.methodOverride());
app.use(express.session({ secret: 'keyboard cat' }));
// Initialize Passport! Also use passport.session() middleware, to support
// persistent login sessions (recommended).
app.use(passport.initialize());
app.use(passport.session());
app.use(app.router);
app.use(express.static(__dirname + '/public'));
});
app.set('views', __dirname + '/views');
app.set('view engine', 'ejs');
app.use(logger());
app.use(cookieParser());
app.use(bodyParser());
app.use(session({ secret: 'keyboard cat' }));
// Initialize Passport! Also use passport.session() middleware, to support
// persistent login sessions (recommended).
app.use(passport.initialize());
app.use(passport.session());
app.use(express.static(__dirname + '/public'));


app.get('/', function(req, res){
Expand Down Expand Up @@ -97,11 +95,7 @@ app.get('/auth/github',
// request. If authentication fails, the user will be redirected back to the
// login page. Otherwise, the primary route function function will be called,
// which, in this example, will redirect the user to the home page.
app.get('/auth/github/callback',
passport.authenticate('github', { failureRedirect: '/login' }),
function(req, res) {
res.redirect('/');
});
app.get('/auth/github/callback', passport.authenticate('github', { successRedirect: '/', failureRedirect: '/login' }));

app.get('/logout', function(req, res){
req.logout();
Expand All @@ -110,7 +104,6 @@ app.get('/logout', function(req, res){

app.listen(3000);


// Simple route middleware to ensure user is authenticated.
// Use this route middleware on any resource that needs to be protected. If
// the request is authenticated (typically via a persistent login session),
Expand Down
4 changes: 4 additions & 0 deletions examples/login/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
"dependencies": {
"express": ">= 0.0.0",
"ejs": ">= 0.0.0",
"morgan": ">=0.0.0",
"cookie-parser": ">=0.0.0",
"body-parser": ">=0.0.0",
"express-session": ">=0.0.0",
"passport": ">= 0.0.0",
"passport-github": ">= 0.0.0"
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"chai": "1.x.x"
},
"engines": {
"node": ">= 0.4.0"
"node": ">= 0.3.0"
},
"scripts": {
"test": "node_modules/.bin/mocha --reporter spec --require test/bootstrap/node test/*.test.js"
Expand Down

0 comments on commit 446c66a

Please sign in to comment.