Repository navigation
Subscribe to rating changes only for an administrator - #43
Merged
Merged
Conversation
The integration now lets every logged-in user read panel_topology. The card subscribed to span_panel_package_ratings_changed whenever its topology came from there, so it now did so for a user who is not an administrator too, and Core, whose allow-list of events anyone may subscribe to leaves this one out, refused each time the card attached, logging an error. canHearRatingChanges() says who may hear the event: an administrator, and only once the frontend says so. The card and the sidebar both ask it, so anyone else's view takes a changed copy as it next reads the topology. The card asks again on every change of Home Assistant, as the sidebar already did, so either subscribes once the frontend says the user is an administrator; the sidebar no longer subscribes before it says so, where a user it then names as no administrator would have been refused. The comments that took panel_topology to be an administrator's alone, and the entity fallback to be how anyone else's card works, now say what holds: the fallback serves an integration that still keeps panel_topology to administrators, and a read that fails.
…istrator A user whose administrator rights went, as a reconnect can find, kept the card's and the sidebar's rating subscriptions, which Core would refuse on each later reconnect, logging an error each time. Once Home Assistant says the user may not hear the event, both now drop them, and subscribe again, once, as it says the user is an administrator.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The card and the sidebar dashboard now subscribe to
span_panel_package_ratings_changedonly for an administrator. Part of the unreleased 0.12.0.The integration is opening
span_panel/panel_topologyto every logged-in user. Before, it was admin-only, which left the sidebar's By Panel, By Activity and By Area views showing "Unauthorized" for non-admins. With the topology open, a non-admin's card would reach its subscription to that event. Home Assistant refuses the subscription, since the event isn't on Core's subscribe allow-list, and logs an ERROR each time.canHearRatingChanges(hass)(hass.user.is_admin === true), decides for both the card and the sidebar. While the user is still unknown, nothing subscribes; an admin subscribes once the frontend names them.82 files and 1540 tests pass, and
dist/is rebuilt.