Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions src/main/java/io/supertokens/storage/postgresql/Start.java
Original file line number Diff line number Diff line change
Expand Up @@ -1480,8 +1480,11 @@ public String[] getRolesForUser(String userId) throws StorageQueryException {

@Override
public String[] getUsersForRole(String role) throws StorageQueryException {
// TODO
return new String[0];
try {
return UserRolesQueries.getUsersForRole(this, role);
} catch (SQLException e) {
throw new StorageQueryException(e);
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,4 +174,14 @@ public static boolean doesRoleExist_transaction(Start start, Connection con, Str
return execute(con, QUERY, pst -> pst.setString(1, role), ResultSet::next);
}

public static String[] getUsersForRole(Start start, String role) throws SQLException, StorageQueryException {
String QUERY = "SELECT user_id FROM " + getConfig(start).getUserRolesTable() + " WHERE role = ? ";
return execute(start, QUERY, pst -> pst.setString(1, role), result -> {
ArrayList<String> userIds = new ArrayList<>();
while (result.next()) {
userIds.add(result.getString("user_id"));
}
return userIds.toArray(String[]::new);
});
}
}