Skip to content

Instantly share code, notes, and snippets.

@vdeturckheim
Created April 10, 2016 16:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vdeturckheim/dbf3868d4461553b4d1a20043790ccab to your computer and use it in GitHub Desktop.
Save vdeturckheim/dbf3868d4461553b4d1a20043790ccab to your computer and use it in GitHub Desktop.
'use strict';
const AuthService = require('../services/auth.service');
// { method: ['GET', 'POST'], path: '/login', config: AuthController.login }
module.exports.login = {
description: 'Sign-in a user in the app',
tags: ['auth'],
auth: 'github',
handler: function (request, reply) {
request.log(['auth'], `login ${request.auth.credentials.username}`);
return reply(AuthService.githubHandler(request.auth.credentials));
}
};
// { method: 'GET', path: '/logout', config: AuthController.logout }
module.exports.logout = {
description: 'lougout a user',
tags: ['auth'],
handler: function (request, reply) {
request.log(['auth'], `logout ${request.auth.credentials._id}`);
return reply(AuthService.removeToken(request.auth.credentials._id));
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment