<commit_before>import * as mongo from 'mongodb';
import * as express from 'express';
import User from './models/user';
import config from './config';

export default (req: express.Request) =>
	new Promise<{ app: any, user: any, isWeb: boolean }>(async (resolve, reject): Promise<void> =>
{
	if (req.body['_i']) {
		const user = await User
			.findOne({_web: req.body['_i']});

		if (user === null) {
			reject('user not found');
			return;
		}

		resolve({
			app: null,
			user: user,
			isWeb: true
		});
		return;
	}

	if (!req.body['_web']) {
		resolve({ app: null, user: null, isWeb: false });
	} else if (req.body['_web'] !== config.webSecret) {
		reject('incorrect key');
	} else if (!req.body['_user']) {
		resolve({ app: null, user: null, isWeb: true });
	} else {
		const id = req.body['_user'];

		const user = await User
			.findOne({_id: new mongo.ObjectID(id)});

		resolve({
			app: null,
			user: user,
			isWeb: true
		});
	}
});
<commit_msg>Fix bug<commit_after>import * as mongo from 'mongodb';
import * as express from 'express';
import User from './models/user';
import config from './config';

export default (req: express.Request) =>
	new Promise<{ app: any, user: any, isWeb: boolean }>(async (resolve, reject): Promise<void> =>
{
	if (req.body['_i']) {
		const user = await User
			.findOne({_web: req.body['_i']});

		if (user === null) {
			reject('user not found');
			return;
		}

		resolve({
			app: null,
			user: user,
			isWeb: true
		});
		return;
	}

	if (!req.body['_web']) {
		resolve({ app: null, user: null, isWeb: false });
	} else if (req.body['_web'] !== config.webSecret) {
		reject('incorrect key');
	} else if (!req.body['_user']) {
		resolve({ app: null, user: null, isWeb: true });
	} else {
		const id = req.body['_user'];

		const user = await User
			.findOne({_id: new mongo.ObjectID(id)});

		if (user === null) {
			reject('user not found');
			return;
		}

		resolve({
			app: null,
			user: user,
			isWeb: true
		});
	}
});

{'fraction_non_alphanumeric': 0.19242424242424241, 'fraction_numerical': 0.0, 'mean_word_length': 3.4120267260579062, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 11, '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': '7444727', 'n_tokens_mistral': 797, 'n_tokens_neox': 711, 'n_words': 208}