Skip to content
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

Update dependencies to the latest versions #5

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
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
30 changes: 21 additions & 9 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ var express = require('express');
var bodyParser = require('body-parser');
var session = require('express-session');
var cookieParser = require('cookie-parser');
var csrf = require('csurf');

/* Requiring the lib */

Expand All @@ -10,18 +11,29 @@ var oauth = require('oauthio');
var app = express();

app.use(express.static('public'));
app.use(bodyParser());
app.use(bodyParser.urlencoded({ extended: false }));
app.use(bodyParser.json());
app.use(cookieParser());
app.use(session({secret: 'keyboard cat', key: 'sid'}));
app.use(session({
secret: 'keyboard cat',
resave: true,
saveUninitialized: false
}));
app.use(csrf());
app.use(function(req, res, next) {
res.cookie('XSRF-TOKEN', req.csrfToken());
res.locals.csrftoken = req.csrfToken();
next();
});

/* Initialization */
try {
var config = require('./config');
var config = require('./config');
} catch (e) {
// Create a config.js file returning an object like the following if you haven't done it yet
var config = {
key: 'your_key',
secret: 'your_secret'
key: '',
secret: ''
};
}

Expand All @@ -44,15 +56,15 @@ app.post('/oauth/signin', function (req, res) {
code: code
})
.then(function (request_object) {
// Here the user is authenticated, and the access token
// Here the user is authenticated, and the access token
// for the requested provider is stored in the session.
// Continue the tutorial or checkout the step-4 to get
// the code for the request
res.send(200, 'The user is authenticated');
res.status(200).send('The user is authenticated');
})
.fail(function (e) {
console.log(e);
res.send(400, 'Code is incorrect');
res.status(400).send('Code is incorrect');
});
});

Expand All @@ -72,7 +84,7 @@ app.get('/me', function (req, res) {
})
.fail(function (e) {
console.log(e);
res.send(400, 'An error occured');
res.status(400).send('An error occured');
});
});

Expand Down
Loading