-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathroutes.js
31 lines (26 loc) · 945 Bytes
/
routes.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
'use strict';
var configRoutes;
var fs = require('fs');
configRoutes = function(app, server, passport) {
app.get('/secret', function(request, response) {
// 認証保護
if(passport.session && passport.session.id){
fs.readFile('./secret/secret.html', 'utf8', function (error, html) {
response.send(html);
});
} else {
response.redirect('/login');
}
});
app.get('/login', function(request, response) {
response.redirect('/login.html');
});
// passport-twitter ----->
// http://passportjs.org/guide/twitter/
app.get('/auth/twitter', passport.authenticate('twitter'));
app.get('/auth/twitter/callback',
passport.authenticate('twitter', { successRedirect: '/secret',
failureRedirect: '/login' }));
// <-----
}
module.exports = {configRoutes: configRoutes};