@Autowired(required = true)
private InvitationService invitationService;
@Override
public User registerUser(UserModel userModel, boolean useTemporaryPassword) {
User user = null;
if (userModel != null) {
List<Role> userRoles = new ArrayList<Role>();
Role userRole = roleService.getRoleByAuthority(UserRole.ROLE_USER.toString());
userRoles.add(userRole);
user = new User(userModel.getEmail(), passwordEncoder.encodePassword(userModel.getPassword(), userModel.getEmail().toLowerCase().trim()), userModel.getEmail(), userModel.getFirstName(), userModel.getLastName(), userRoles);
user.setPasswordExpired(useTemporaryPassword);
//If this is the first user in the application, set them as a Knappsack administrator
if (userService.countAll() == 0) {
setAdminRole(user);
}
userDetailsDao.add(user);