Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
'Unrecognized options for create user request',
{
username: user && user.username,
email: user && user.email,
},
400,
);
}
// In case where password is an object we assume it was prevalidated and hashed
if (!user.password ||
(isString(user.password) && !validators.validatePassword(user.password))) {
throw new AccountsError('Password is required');
}
if (!validators.validateUsername(user.username) && !validators.validateEmail(user.email)) {
throw new AccountsError('Username or Email is required');
}
const hashAlgorithm = this.options.passwordHashAlgorithm;
const password = (user.password && hashAlgorithm) ?
hashPassword(user.password, hashAlgorithm) : user.password;
const userToCreate = { ...user, password };
try {
const userId = await this.transport.createUser(userToCreate);
const { onUserCreated } = this.options;
if (callback && isFunction(callback)) {
callback();
}
if (isFunction(onUserCreated)) {
try {
await onUserCreated({ id: userId });