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 @@ -1498,8 +1498,11 @@ public String[] getPermissionsForRole(String role) throws StorageQueryException

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

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -210,4 +210,20 @@ public static int deleteAllPermissionsForRole_Transaction(Start start, Connectio

}

public static String[] getRolesThatHavePermission(Start start, String permission)
throws SQLException, StorageQueryException {

String QUERY = "SELECT role FROM " + getConfig(start).getUserRolesPermissionsTable() + " WHERE permission = ? ";

return execute(start, QUERY, pst -> pst.setString(1, permission), result -> {
ArrayList<String> roles = new ArrayList<>();

while (result.next()) {
roles.add(result.getString("role"));
}

return roles.toArray(String[]::new);
});
}

}