<commit_before>/**
 * AuthController
 *
 * @description Authenticaiton logic and JWT generation
 *
 */
/**
 * @apiDefine badRequestError
 * @apiError BadRequest Parameters are not valid for this api endpoint
 * @apiErrorExample BadRequest
 *     HTTP/1.1 400 Bad Request
 *     {
 *         "_error": {
 *             code: 400,
 *             status: 'BadRequest',
 *             message: 'Parameters are not valid for this api endpoint'
 *         }
 *     }
 *
 */
/**
 * @apiDefine jwtSuccess
 * @apiSuccess {String} jwt JWT (JSON Web Token) that you have to use
 * to authenticate against other API endpoints. Here is how to use it:
 * * For HTTP requests, you have to set an header `Authorization: Bearer [Your JWT token]`
 * * For Web socket requests, you are already authenticated after this method, because you JWT has been associated with your socket. But if you need to open a new socket with this JWT, you can authenticate with the `/auth/jwt` endpoint
 * @apiSuccessExample Success
 *     HTTP/1.1 200 OK
 *     {
 *       "jwt": "<KEY>"
 *     }
 */


module.exports = {

    /**
     * @api {post} /login/ip Authenticate user by IP
     * @apiName ipLogin
     * @apiGroup Authentication
     * @apiDescription Will try to authenticate with the IP used by the client
     * that send the request.
     *
     * @apiUse jwtSuccess
     *
     * @apiError IPNotFound There is no User associated with this IP
     * @apiErrorExample IPNotFound
     *     HTTP/1.1 401 Unauthorized
     *     {
     *         "_error": {
     *             code: 401,
     *             status: 'IPNotFound',
     *             message: 'There is no User associated with this IP'
     *         }
     *     }
     *
     */
    ipLogin: function (req, res) {
        console.log('Ip Log attempt ',req.ip);
        User.attemptIpAuth((req.ip ? req.ip.split(',')[0] : req.headers['x-forwarded-for'].split(',')[0]), (err, user) => {
            if (err) {
                return res.negotiate(err);
            }
            if (!user) {<commit_msg>Remove the nasty log <3<commit_after>/**
 * AuthController
 *
 * @description Authenticaiton logic and JWT generation
 *
 */
/**
 * @apiDefine badRequestError
 * @apiError BadRequest Parameters are not valid for this api endpoint
 * @apiErrorExample BadRequest
 *     HTTP/1.1 400 Bad Request
 *     {
 *         "_error": {
 *             code: 400,
 *             status: 'BadRequest',
 *             message: 'Parameters are not valid for this api endpoint'
 *         }
 *     }
 *
 */
/**
 * @apiDefine jwtSuccess
 * @apiSuccess {String} jwt JWT (JSON Web Token) that you have to use
 * to authenticate against other API endpoints. Here is how to use it:
 * * For HTTP requests, you have to set an header `Authorization: Bearer [Your JWT token]`
 * * For Web socket requests, you are already authenticated after this method, because you JWT has been associated with your socket. But if you need to open a new socket with this JWT, you can authenticate with the `/auth/jwt` endpoint
 * @apiSuccessExample Success
 *     HTTP/1.1 200 OK
 *     {
 *       "jwt": "<KEY>"
 *     }
 */


module.exports = {

    /**
     * @api {post} /login/ip Authenticate user by IP
     * @apiName ipLogin
     * @apiGroup Authentication
     * @apiDescription Will try to authenticate with the IP used by the client
     * that send the request.
     *
     * @apiUse jwtSuccess
     *
     * @apiError IPNotFound There is no User associated with this IP
     * @apiErrorExample IPNotFound
     *     HTTP/1.1 401 Unauthorized
     *     {
     *         "_error": {
     *             code: 401,
     *             status: 'IPNotFound',
     *             message: 'There is no User associated with this IP'
     *         }
     *     }
     *
     */
    ipLogin: function (req, res) {
        User.attemptIpAuth((req.ip ? req.ip.split(',')[0] : req.headers['x-forwarded-for'].split(',')[0]), (err, user) => {
            if (err) {
                return res.negotiate(err);
            }
            if (!user) {
{'fraction_non_alphanumeric': 0.107981220657277, 'fraction_numerical': 0.011613540894489745, 'mean_word_length': 2.068991660348749, 'pattern_counts': {'":': 6, '<': 6, '<?xml version=': 0, '>': 7, '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': '4717986', 'n_tokens_mistral': 1214, 'n_tokens_neox': 1161, 'n_words': 408}