<commit_before>
var express = require('express');
var router = express.Router();
var Subject = require('../models/subject');
var Classification = require('../models/classification');
var passport = require('passport');


function ensureAuthenticated(req, res, next) {
    if (req.isAuthenticated()) {
        return next();
    }
    res.redirect('/');
}


router.get('/auth/github', passport.authenticate('github'), function(req, res) {
});


router.get('/auth/github/callback', passport.authenticate('github', { failureRedirect: '/' }), function(req, res) {
    res.redirect('/');
});


router.post('/classification', ensureAuthenticated, function(req, res) {
    
    var c = new Classification();
    c.cloudy = req.body.isCloudy;
    c.subject_id = req.body.subjectId;
    c.volunteer = req.user.username;
    c.save(function(err, doc) {
      return res.json({"BOO": "YA"});
    });
});


router.get('/subject', ensureAuthenticated, function(req, res) {
    
    Subject.random(function(err, subject) {
        return res.json(subject);
    });
    
});


module.exports = router;<commit_msg>endpoint to check user<commit_after>
var express = require('express');
var router = express.Router();
var Subject = require('../models/subject');
var Classification = require('../models/classification');
var passport = require('passport');


function ensureAuthenticated(req, res, next) {
    if (req.isAuthenticated()) {
        return next();
    }
    res.redirect('/');
}


router.get('/auth/github', passport.authenticate('github'), function(req, res) {
});


router.get('/auth/github/callback', passport.authenticate('github', { failureRedirect: '/' }), function(req, res) {
    res.redirect('/');
});


router.get('/user', function(req, res) {
    var msg = {user: null};
    
    msg.user = req.isAuthenticated() ? req.user.username : false;
    return res.status(200).json(msg);
});


router.post('/classification', ensureAuthenticated, function(req, res) {
    
    var c = new Classification();
    c.cloudy = req.body.isCloudy;
    c.subject_id = req.body.subjectId;
    c.volunteer = req.user.username;
    c.save(function(err, doc) {
      return res.json(200, {"BOO": "YA"});
    });
});


router.get('/subject', ensureAuthenticated, function(req, res) {
    
    Subject.random(function(err, subject) {
        return res.json(subject);
    });
    
});


module.exports = router;
{'fraction_non_alphanumeric': 0.18295739348370926, 'fraction_numerical': 0.002506265664160401, 'mean_word_length': 3.668615984405458, 'pattern_counts': {'":': 2, '<': 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': '1149718', 'n_tokens_mistral': 773, 'n_tokens_neox': 734, 'n_words': 144}