Search in sources :

Example 1 with OrganizationModification

use of alfio.model.modification.OrganizationModification in project alf.io by alfio-event.

the class UserCreatorBeforeLoginFilter method doFilter.

@Override
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
    HttpServletRequest req = (HttpServletRequest) request;
    // ensure organization/user
    if (requestMatcher.matches(req) && req.getParameter("username") != null && req.getParameter("password") != null) {
        String username = req.getParameter("username");
        if (!userManager.usernameExists(username)) {
            var organizationModification = new OrganizationModification(null, "Demo organization", username, username, null, null);
            int orgId = userManager.createOrganization(organizationModification);
            userManager.insertUser(orgId, username, "", "", username, Role.OWNER, User.Type.DEMO, req.getParameter("password"), null, null);
        }
    }
    chain.doFilter(request, response);
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) OrganizationModification(alfio.model.modification.OrganizationModification)

Aggregations

OrganizationModification (alfio.model.modification.OrganizationModification)1 HttpServletRequest (javax.servlet.http.HttpServletRequest)1