<commit_before>"use strict";

var DBHouse = require('dbhouse');

// Metadata
module.exports = {
	type: 'engine',
	engine_name: 'Admin',
	prototype: require('./prototype'),
	statuscode: {
		SYSERR: -1,
		EMPTY: 0,
		INVALID: 1,
		EXISTS: 2,
		NONEXIST: 3,
		NOPERM: 4
	},
	check_permission: function(conn, callback) {

		if (!conn.req.session.username)
			callback(false);

		if (!conn.req.session.permission)
			callback(false);

		if (conn.req.session.permission.admin) {
			callback(true);
		} else {
			callback(false);
		}
	}
};<commit_msg>Fixed a bug that check permission cause crash on admin engine<commit_after>"use strict";

var DBHouse = require('dbhouse');

// Metadata
module.exports = {
	type: 'engine',
	engine_name: 'Admin',
	prototype: require('./prototype'),
	statuscode: {
		SYSERR: -1,
		EMPTY: 0,
		INVALID: 1,
		EXISTS: 2,
		NONEXIST: 3,
		NOPERM: 4
	},
	check_permission: function(conn, callback) {

		if (!conn.req.session.username) {
			callback(false);
			return;
		}

		if (!conn.req.session.permission) {
			callback(false);
			return;
		}

		if (conn.req.session.permission.admin) {
			callback(true);
		} else {
			callback(false);
		}
	}
};
{'fraction_non_alphanumeric': 0.1606837606837607, 'fraction_numerical': 0.010256410256410256, 'mean_word_length': 3.592156862745098, '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': '3585697', 'n_tokens_mistral': 485, 'n_tokens_neox': 422, 'n_words': 92}