Skip to content

Commit

Permalink
#1054 prevent duplications when in demo mode
Browse files Browse the repository at this point in the history
  • Loading branch information
cbellone committed Mar 27, 2022
1 parent 1372fb4 commit c813d22
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,9 @@
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;
import java.util.UUID;

// generate a user if it does not exists, to be used by the demo profile
// generate a user if it does not exist, to be used by the demo profile
public class UserCreatorBeforeLoginFilter extends GenericFilterBean {

private final UserManager userManager;
Expand All @@ -51,7 +52,7 @@ public void doFilter(ServletRequest request, ServletResponse response, FilterCha
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);
var organizationModification = new OrganizationModification(null, UUID.randomUUID().toString(), username, username, null, null);
int orgId = userManager.createOrganization(organizationModification);
userManager.insertUser(orgId, username, "", "", username, Role.OWNER, User.Type.DEMO, req.getParameter("password"), null, null);
}
Expand Down

0 comments on commit c813d22

Please sign in to comment.