hashedPassword = Password.validateAndCreateCustom(userPasswordPolicy, user, null, null, password);
} else {
hashedPassword = Password.validateAndCreateCustom(passwordPolicy, null, null, password);
}
} catch (PasswordException error) {
throw new AuthenticationException(error);
}
user.setName(name);
if (atAt >= 0) {
user.setEmail(username);
} else {
user.setUsername(username);
}
user.setPassword(hashedPassword);
user.save();
return user;
}
throw new AuthenticationException(
"Oops! No user with that username and password.");
}