joyent-portal/spikes/auth/bell/src/routes/auth.js

36 lines
868 B
JavaScript
Raw Normal View History

2016-11-17 16:16:10 +02:00
const path = require('path');
module.exports = (server) => {
server.route({
method: ['GET', 'POST'],
path: '/auth/twitter',
config: {
auth: 'twitter',
handler: (request, reply) => {
if (!request.auth.isAuthenticated) {
return reply('Authentication failed due to: ' + request.auth.error.message);
}
reply(`Welcome ${request.auth.credentials.profile.displayName}`);
}
}
});
server.route({
method: ['GET', 'POST'],
path: '/auth/github',
config: {
auth: 'github',
handler: (request, reply) => {
if (!request.auth.isAuthenticated) {
return reply('Authentication failed due to: ' + request.auth.error.message);
}
console.log(request.auth);
reply(`Welcome ${request.auth.credentials.profile.displayName}`);
}
}
});
};