<commit_before>const express = require('express');
const router = express.Router();

router.use(requireAdmin);

/* GET home page. */
router.get('/', (req, res, next) => {
    
    res.render('administration/index');
});

router.get('/unverified', (req, res, next) => {
    req.db.User.find({ verified: false })
        .exec()
        .then(users => {
            res.locals.unverifiedUsers = users;

            res.render('administration/unverified');
        })
        .catch(next);
});

router.post('/verify/:id', (req, res, next) => {
    req.db.User.findById(req.params.id)
        .exec()
        .then(user => {
            user.verified = true;
            const rank = req.body.rank;
            if(rank < 0 || rank > 3) return next(new Error('Invalid rank!'));
            
            user.rank = rank;
            return user.save();
        })
        .then(() => {
            req.flash('success', 'Successfully verified user.');
            res.redirect('/unverified');
        })
        .catch(next);
});

module.exports = router;<commit_msg>Admins can verify users<commit_after>const express = require('express');
const router = express.Router();

router.use(requireAdmin);

/* GET home page. */
router.get('/', (req, res, next) => {
    
    res.render('administration/index');
});

router.get('/unverified', (req, res, next) => {
    req.db.User.find({ verified: false })
        .exec()
        .then(users => {
            res.locals.unverifiedUsers = users;

            res.render('administration/unverified');
        })
        .catch(next);
});

router.post('/verify/:id', (req, res, next) => {
    req.db.User.findById(req.params.id)
        .exec()
        .then(user => {
            user.verified = true;
            const rank = req.body.rank;
            if(rank < 0 || rank > 3) return next(new Error('Invalid rank!'));
            
            user.rank = rank;
            return user.save();
        })
        .then(() => {
            req.flash('success', 'Successfully verified user.');
            res.redirect('/administration/unverified');
        })
        .catch(next);
});

module.exports = router;
{'fraction_non_alphanumeric': 0.1783884489986027, 'fraction_numerical': 0.0018630647414997672, 'mean_word_length': 1.9791955617198336, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 17, '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': '3731391', 'n_tokens_mistral': 649, 'n_tokens_neox': 640, 'n_words': 124}