if (usersWithSameName.isEmpty()) {
// Get authentication type
HttpServletRequest request = ((ServletWebRequest) RequestCycle.get().getRequest()).getContainerRequest();
Authentication authentication = (Authentication) request.getSession().getAttribute(Pac4jAuthenticationUtils.AUTH_TOKEN_ATTRIBUTE);
AuthenticationType authenticationType = Pac4jAuthenticationUtils.getAuthenticationType(authentication);
userService.register(user, authenticationType, passwordValue);
// Reset authentication session attribute
request.getSession().removeAttribute(Pac4jAuthenticationUtils.AUTH_TOKEN_ATTRIBUTE);