<commit_before>
const express  = require('express');
const router   = express.Router();
const Authentication = require('../controllers/authentication');
const passportService = require('../services/passport');
const passport = require('passport');

const requireAuth = passport.authenticate('jwt', { session: false });
const requireSignin = passport.authenticate('local', { session: false });


router.route('/logout').get(function(req, res) {
	// FIXME: token is still in memory... how can I revoke it?
	req.logout();
	res.send(200);
});

// Ping if is logged in
router.route('/loggedin').get(function(req, res) {
	//res.send(req.isAuthenticated() ? { 'user': req.user } : '0');
});

router.route('/signin').post(requireSignin, Authentication.signin);
router.route('/signup').post(Authentication.signup);


module.exports = router;<commit_msg>service to retrieve logged user<commit_after>
const express  = require('express');
const router   = express.Router();
const Authentication = require('../controllers/authentication');
const passportService = require('../services/passport');
const passport = require('passport');

const requireAuth = passport.authenticate('jwt', { session: false });
const requireSignin = passport.authenticate('local', { session: false });


router.route('/logout').get(function(req, res) {
	// FIXME: token is still in memory... how can I revoke it?
	// TODO delete token
	// req.logout();
	res.status(200).json({message: "logged out"});
});

// Return the logged user
// TODO: refresh token?
router.route('/loggedin').get(requireAuth, function(req, res) {
	res.json({ 'user': req.user });
});

router.route('/signin').post(requireSignin, Authentication.signin);
router.route('/signup').post(Authentication.signup);


module.exports = router;
{'fraction_non_alphanumeric': 0.17853107344632768, 'fraction_numerical': 0.0039548022598870055, 'mean_word_length': 5.302491103202847, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1170191', 'n_tokens_mistral': 540, 'n_tokens_neox': 519, 'n_words': 124}