diff --git a/src/main/java/io/supertokens/webserver/api/userroles/AddUserRoleAPI.java b/src/main/java/io/supertokens/webserver/api/userroles/AddUserRoleAPI.java index 973848e1f..397091c47 100644 --- a/src/main/java/io/supertokens/webserver/api/userroles/AddUserRoleAPI.java +++ b/src/main/java/io/supertokens/webserver/api/userroles/AddUserRoleAPI.java @@ -48,7 +48,7 @@ public String getPath() { @Override protected void doPut(HttpServletRequest req, HttpServletResponse resp) throws IOException, ServletException { - // API is tenant specific + // API is tenant specific, but uses public tenant storage JsonObject input = InputParser.parseJsonObjectOrThrowError(req); String userId = InputParser.parseStringOrThrowError(input, "userId", false); String role = InputParser.parseStringOrThrowError(input, "role", false); @@ -61,7 +61,8 @@ protected void doPut(HttpServletRequest req, HttpServletResponse resp) throws IO try { boolean didUserAlreadyHaveRole = !UserRoles.addRoleToUser( - this.getTenantStorage(req), userId, role); + this.getTenantStorage(req).withStorage(this.getPublicTenantStorage(req).getStorage()), + userId, role); JsonObject response = new JsonObject(); response.addProperty("status", "OK"); response.addProperty("didUserAlreadyHaveRole", didUserAlreadyHaveRole); diff --git a/src/main/java/io/supertokens/webserver/api/userroles/GetRolesForUserAPI.java b/src/main/java/io/supertokens/webserver/api/userroles/GetRolesForUserAPI.java index 2f0e52c42..4ce961a6a 100644 --- a/src/main/java/io/supertokens/webserver/api/userroles/GetRolesForUserAPI.java +++ b/src/main/java/io/supertokens/webserver/api/userroles/GetRolesForUserAPI.java @@ -48,11 +48,11 @@ public String getPath() { @Override protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException, ServletException { - // API is tenant specific + // API is tenant specific, but using the public tenant storage String userId = InputParser.getQueryParamOrThrowError(req, "userId", false); try { - - String[] userRoles = UserRoles.getRolesForUser(this.getTenantStorage(req), + String[] userRoles = UserRoles.getRolesForUser( + this.getTenantStorage(req).withStorage(this.getPublicTenantStorage(req).getStorage()), userId); JsonArray arr = new JsonArray(); for (String s : userRoles) { diff --git a/src/main/java/io/supertokens/webserver/api/userroles/GetUsersForRoleAPI.java b/src/main/java/io/supertokens/webserver/api/userroles/GetUsersForRoleAPI.java index 655ac5d7b..6743f89c0 100644 --- a/src/main/java/io/supertokens/webserver/api/userroles/GetUsersForRoleAPI.java +++ b/src/main/java/io/supertokens/webserver/api/userroles/GetUsersForRoleAPI.java @@ -49,7 +49,7 @@ public String getPath() { @Override protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException, ServletException { - // API is tenant specific + // API is tenant specific, but uses public tenant storage String role = InputParser.getQueryParamOrThrowError(req, "role", false); // normalize roles @@ -60,8 +60,9 @@ protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws IO } try { - - String[] roleUsers = UserRoles.getUsersForRole(this.getTenantStorage(req), role); + String[] roleUsers = UserRoles.getUsersForRole( + this.getTenantStorage(req).withStorage(this.getPublicTenantStorage(req).getStorage()), + role); JsonArray arr = new JsonArray(); for (String s : roleUsers) { diff --git a/src/main/java/io/supertokens/webserver/api/userroles/RemoveUserRoleAPI.java b/src/main/java/io/supertokens/webserver/api/userroles/RemoveUserRoleAPI.java index 6c40b6f6f..4eb665fd9 100644 --- a/src/main/java/io/supertokens/webserver/api/userroles/RemoveUserRoleAPI.java +++ b/src/main/java/io/supertokens/webserver/api/userroles/RemoveUserRoleAPI.java @@ -48,7 +48,7 @@ public String getPath() { @Override protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws IOException, ServletException { - // API is tenant specific + // API is tenant specific, but uses public tenant storage JsonObject input = InputParser.parseJsonObjectOrThrowError(req); String userId = InputParser.parseStringOrThrowError(input, "userId", false); String role = InputParser.parseStringOrThrowError(input, "role", false); @@ -60,7 +60,8 @@ protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws I } try { - boolean didUserHaveRole = UserRoles.removeUserRole(this.getTenantStorage(req), + boolean didUserHaveRole = UserRoles.removeUserRole( + this.getTenantStorage(req).withStorage(this.getPublicTenantStorage(req).getStorage()), userId, role); JsonObject response = new JsonObject();