src/middleware/auth.js
async function createUser (username, password, /* istanbul ignore next */ body = {}) {
	const user = await getUser(username, password);
	body[configuration.security.username] = username;
	body[configuration.security.password] = await hash(password, 5);
	if (user === null) {
		return AuthModel.create(body);
	} else {
		return Promise.resolve({
			error: 'User Already Extis'
		});
	}
}
async function createUser (username, password, /* istanbul ignore next */ body = {}) {
	const user = await getUser(username, password);
	body[configuration.security.username] = username;
	body[configuration.security.password] = await hash(password, 5);
	if (user === null) {
		return AuthModel.create(body);
	} else {
		return Promise.resolve({
			error: 'User Already Extis'
		});
	}
}
async function createUser ( username , password , /* istanbul ignore next */ body = { } ) { const user = await getUser ( username , password ) ; body [ configuration . security . username ] = username ; body [ configuration . security . password ] = await hash ( password , 5 ) ; if ( user === null ) { return AuthModel . create ( body ) ; } else { return Promise . resolve ( { error : 'User Already Extis' } ) ; } }
Creates and user if it does not exits in the database.
@param {String} username - Data that represents the username field in the target model.
@param {String} passowrd - Unencrypted data that represents the username field in the target model.
@param {Object} [body={}] - Information that might be passed to the model creation.
@return {Promise<AuthModel>} - if callback is not set it will return a promise
Creates and user if it does not exits in the database .