<commit_before>/**
 * User authentication model will authenticate the username and password in your database. If they are matching
 * then an auth token is created and returned. This token should be used for the remainder of your requests.
 */

var db = require('../../db'),
    q = require('q'),
    Strings = require('../../strings'),
    uuid  = require('node-uuid'),
    strings = new Strings('en'),
    err = new Error(strings.group('errors').invalid_username);

err.code = strings.group('codes').unauthorized;

module.exports = {
    auth: function(options){
        'use strict';
        var deferred = q.defer();

        console.log('got to line 20 of basic auth in core');

        db.users.basicAuthentication(options.username, options.password)
            .then(function(user){
                var t = uuid.v4();

                db.tokens.insert({
                    _id: t,
                    uid: user._id,
                    created: new Date().toISOString()
                })
                    .then(function(){
                        deferred.resolve(t);
                    });
            })
            .fail(function(){
                deferred.reject(err);
            })
            .done();

        return deferred.promise;
    }
};
<commit_msg>Removed the hardcoded oauthCallback and moved it onto the GHAPI config.<commit_after>/**
 * User authentication model will authenticate the username and password in your database. If they are matching
 * then an auth token is created and returned. This token should be used for the remainder of your requests.
 */

var db = require('../../db'),
    q = require('q'),
    Strings = require('../../strings'),
    uuid  = require('node-uuid'),
    strings = new Strings('en'),
    err = new Error(strings.group('errors').invalid_username);

err.code = strings.group('codes').unauthorized;

module.exports = {
    auth: function(options){
        'use strict';
        var deferred = q.defer();

        db.users.basicAuthentication(options.username, options.password)
            .then(function(user){
                var t = uuid.v4();

                db.tokens.insert({
                    _id: t,
                    uid: user._id,
                    created: new Date().toISOString()
                })
                    .then(function(){
                        deferred.resolve(t);
                    });
            })
            .fail(function(){
                deferred.reject(err);
            })
            .done();

        return deferred.promise;
    }
};

{'fraction_non_alphanumeric': 0.1264682850430697, 'fraction_numerical': 0.0015661707126076742, 'mean_word_length': 1.6810073452256034, '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': '6695729', 'n_tokens_mistral': 665, 'n_tokens_neox': 627, 'n_words': 183}