<commit_before>import * as bcrypt from 'bcrypt';
import {User} from '../../models';
import {IApplication, IUser} from '../../interfaces';
import {isScreenName} from '../../spec';

export default function(app: IApplication, screenName: string, password: string): Promise<IUser> {
	'use strict';

	return (app !== null) ?
		<Promise<any>>Promise.reject('access-denied')
	: (screenName === undefined || screenName === null || screenName === '') ?
		<Promise<any>>Promise.reject('empty-screen-name')
	: (!isScreenName(screenName) || screenName.length < 3) ?
		<Promise<any>>Promise.reject('invalid-screen-name')
	: (password === <PASSWORD> || password === null || password === '') ?
		<Promise<any>>Promise.reject('empty-password')
	:
		(() => {
			// Generate hash of password
			const salt = bcrypt.genSaltSync(14);
			const encryptedPassword = bcrypt.hashSync(password, salt);

			return Promise.resolve(User.create({
				screenName: screenName,
				screenNameLower: screenName.toLowerCase(),
				name: 'no name',
				lang: 'ja',
				credit: 3000,
				encryptedPassword: <PASSWORD>
			}));
		})();
}<commit_msg>Fix bug<commit_after>import * as bcrypt from 'bcrypt';
import {User} from '../../models';
import {IApplication, IUser} from '../../interfaces';
import {isScreenName} from '../../spec';

export default function(app: IApplication, screenName: string, password: string, isOfficial: boolean): Promise<IUser> {
	'use strict';

	return (!isOfficial) ?
		<Promise<any>>Promise.reject('access-denied')
	: (screenName === undefined || screenName === null || screenName === '') ?
		<Promise<any>>Promise.reject('empty-screen-name')
	: (!isScreenName(screenName) || screenName.length < 3) ?
		<Promise<any>>Promise.reject('invalid-screen-name')
	: (password === <PASSWORD> || password === null || password === '') ?
		<Promise<any>>Promise.reject('empty-password')
	:
		(() => {
			// Generate hash of password
			const salt = bcrypt.genSaltSync(14);
			const encryptedPassword = bcrypt.hashSync(password, salt);

			return Promise.resolve(User.create({
				screenName: screenName,
				screenNameLower: screenName.toLowerCase(),
				name: 'no name',
				lang: 'ja',
				credit: 3000,
				encryptedPassword: <PASSWORD>
			}));
		})();
}
{'fraction_non_alphanumeric': 0.18710832587287377, 'fraction_numerical': 0.006266786034019696, 'mean_word_length': 4.451219512195122, 'pattern_counts': {'":': 0, '<': 27, '<?xml version=': 0, '>': 27, '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': '7035672', 'n_tokens_mistral': 762, 'n_tokens_neox': 678, 'n_words': 152}