<commit_before>auth = require 'basic-auth'
Q = require "q"
Client = require("../model/clients").Client
logger = require "winston"
crypto = require "crypto"

exports.authenticateUser = (ctx, done) ->

	Client.findOne { clientID: ctx.request.header.clientid }, (err, client) ->
		ctx.authenticated = client
		ctx.parentID = ctx.request.header.parentid
		done null, client
	

###
# Koa middleware for authentication by basic auth
###
exports.koaMiddleware = `function *rerunBypassAuthMiddleware(next) {
	
	var authenticateUser = Q.denodeify(exports.authenticateUser);
	yield authenticateUser(this);

	if (this.authenticated) {
		yield next;
	} else {
		this.response.status = "unauthorized";
	}
	
}`<commit_msg>Client id bug fix<commit_after>auth = require 'basic-auth'
Q = require "q"
Client = require("../model/clients").Client
logger = require "winston"
crypto = require "crypto"

exports.authenticateUser = (ctx, done) ->

	Client.findOne { _id: ctx.request.header.clientid }, (err, client) ->
		ctx.authenticated = client
		ctx.parentID = ctx.request.header.parentid
		done null, client
	

###
# Koa middleware for authentication by basic auth
###
exports.koaMiddleware = `function *rerunBypassAuthMiddleware(next) {
	
	var authenticateUser = Q.denodeify(exports.authenticateUser);
	yield authenticateUser(this);

	if (this.authenticated) {
		yield next;
	} else {
		this.response.status = "unauthorized";
	}
	
}`
{'fraction_non_alphanumeric': 0.1314487632508834, 'fraction_numerical': 0.0, 'mean_word_length': 4.619047619047619, 'pattern_counts': {'":': 0, '<': 3, '<?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': '5892927', 'n_tokens_mistral': 488, 'n_tokens_neox': 451, 'n_words': 105}