Repository navigation
fix(auth): have open pages follow a change of access - #735
Merged
Merged
Conversation
An admin page checked the role once, as it mounted, and then handed every later action the account it had loaded then. The admin policies read the role off that account, so an administrator whose role was removed could keep promoting, suspending, restoring and working the report queue from a page that was already open. The admin pages now read the role from the database before each event and each change of address, and leave for the agenda once it is gone. The policies still read the role off the actor they are given. Every other caller loads that actor per request, so only an open page could hold a stale one, and asking again here is a smaller change than a database read in every admin policy.
A page authorizes when it mounts and then keeps the account it loaded for as long as it stays open. Three changes left that copy behind: - a new password revoked every session, but a page already open kept working until its socket happened to reconnect - an account role change reached nobody's open pages - a change of group role or the end of a membership refreshed the sidebar and left the page in place, so the huddl forms and the Locations page kept the group's address book after an organizer lost the role Each of these now announces itself on a per-person topic once it has committed, and every open page of that person visits itself again. The fresh mount verifies the session, reloads the account and lets the page's own rules decide: someone still allowed stays where they were, anyone else lands where a new visit would. The process that made the change is skipped, so the page a person changes their password or leaves a group from behaves as it did. Joining a group or being added to one still only refreshes in place; nothing is taken away by those. Pages that patched themselves in place for the affected person now reload instead, so the steps that change someone's access from another session follow the open page before asserting on it.
A member's role change or removal told their open pages as soon as the action finished, so a change rolled back by a surrounding transaction still reloaded them. Both now go out through the membership notifier, which speaks only after the outermost commit. Permanently deleting a group now reaches its members' open pages too: the memberships go with the group.
The members told about a deleted group were read before the group's row was locked, so someone whose membership committed in between lost it without their open pages hearing. The row is locked first, as joining and adding a member already do.
…vocation * origin/main: fix(api): accept only sign-in tokens on the GraphQL socket (#730) fix(huddl): tie organizer-only huddl details to the current role (#726) fix(groups): keep a group's address book with its organizers (#725) fix(discover): noindex empty filtered public discovery responses (#734)
…hanges A connecting page read its account from the session and only then began listening for changes to that person's access, so a new password or a changed role that committed in between went unheard and the page stayed signed in on a session that had just ended. The page now listens first and then checks that the session's token still verifies and the account's role and standing are the ones it loaded; if not, it visits itself again.
…vocation * origin/main: fix(api): authenticate API, GraphQL and MCP from the bearer alone (#729)
…ion at mount A role change told the person's pages to refresh in place before telling them to visit themselves again, so a page of results had already moved to its first page when it read its own address. The visit-again signal now goes first. A connecting page also starts listening for suspension before it checks what it loaded, and the admin pages read the role again only once connected.
…vocation * origin/main: fix(auth): bind administrator viewing credentials to the browser session (#736) # Conflicts: # lib/huddlz_web/live_user_auth.ex
A transfer refreshed both people's pages in place from its own hook, before the role changes told those pages to visit themselves again, and it did so even when a surrounding transaction rolled back. The hook is gone: the two role changes already announce themselves once the outermost transaction commits, each person's page first and the roster after.
…e, about access changes An owner whose membership row is missing had no role change to announce a handover and was not among the members told of a permanent deletion, so their open pages kept showing the group. The handover now names them and the deletion counts the group's owner. The sign-out page ran only the first of its two mount steps, so it never listened; it now runs both in one stage.
…vocation * origin/main: fix(groups): authorize membership changes against their roster (#739) # Conflicts: # lib/huddlz/communities/group_member/changes/notify_role_changed.ex
A change is announced by its notifiers once the transaction that holds it commits. The overlap tests held a change open in a bare repo transaction, which Ash cannot see commit, so a promotion that committed while a second request waited was never announced to the member's pages or an open roster. No caller under lib/ wraps a membership action that way; the helper now uses Ash.transact/2 as they do, and the overlap test observes both transitions in order: the promotion, then the change back.
…llow it A permanent deletion published the group's own change before it told each member's open pages to visit themselves again. The organizer Social page follows the group, so it heard the first, found no group and moved on with a note about changed organizer access. The members' signal now goes out first: the page visits its own address and its mount gives the answer a new visit gets. Deletion is the only group action that sends both.
…isits itself An address reaches the server without its fragment, so the visit a page makes when its person's access changes came back at the path and query alone: someone who had followed the skip link lost "#main-content" from the address, and focus fell from the main landmark to the document body. The server still sends the page at once, whatever the browser does, and now says a visit is coming just before. The browser notes where the person is and, when the page is back at the same path and query, returns the fragment to the same history entry and returns focus to the element that had it, or else to the one the fragment names. A page that is turned away is at another address and is left as it landed.
A page mounting with a changed role now continues in place with the current role and suspension details; only an ended session redirects. The revisit helper acts only on the visit it announced, and the roster concurrency test waits on the database's own lock report.
The admin pages ran their admin gate before the hook that re-reads the account once the page is listening, so an administrator demoted while a page connected passed the gate and the page's own mount was refused mid-join. The gate now runs second, and the mount test runs each admin page's hooks in the order it declares them, followed by its mount.
mwoods79
enabled auto-merge (squash)
December 1, 2026 20:14
mwoods79
added a commit
that referenced
this pull request
Dec 1, 2026
* origin/main: fix(auth): have open pages follow a change of access (#735)
mwoods79
added a commit
that referenced
this pull request
Dec 1, 2026
* origin/main: fix(auth): have open pages follow a change of access (#735)
mwoods79
added a commit
that referenced
this pull request
Dec 1, 2026
* origin/main: fix(auth): have open pages follow a change of access (#735) fix(groups): authorize membership changes against their roster (#739) fix(auth): bind administrator viewing credentials to the browser session (#736) fix(api): authenticate API, GraphQL and MCP from the bearer alone (#729) fix(api): accept only sign-in tokens on the GraphQL socket (#730) fix(huddl): tie organizer-only huddl details to the current role (#726) fix(groups): keep a group's address book with its organizers (#725) fix(discover): noindex empty filtered public discovery responses (#734)
mwoods79
added a commit
that referenced
this pull request
Dec 1, 2026
…n-escaping * origin/main: fix(groups): hold a group's slug to one rule whenever it is set (#742) fix(huddl): copy only huddlz the actor can organize (#723) fix(auth): have open pages follow a change of access (#735) fix(groups): authorize membership changes against their roster (#739) fix(auth): bind administrator viewing credentials to the browser session (#736)
mwoods79
added a commit
that referenced
this pull request
Dec 1, 2026
…d-sorts * origin/main: fix(auth): have open pages follow a change of access (#735) fix(groups): authorize membership changes against their roster (#739) fix(auth): bind administrator viewing credentials to the browser session (#736) fix(api): authenticate API, GraphQL and MCP from the bearer alone (#729) fix(api): accept only sign-in tokens on the GraphQL socket (#730) fix(huddl): tie organizer-only huddl details to the current role (#726) fix(groups): keep a group's address book with its organizers (#725) fix(discover): noindex empty filtered public discovery responses (#734)
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.
Summary
A page authorizes when it mounts and then keeps the account it loaded for as long as it stays open. A new password, a changed account role, a changed group role or the end of a membership now reach the pages that person already has open: each page visits itself again, so its own mount decides afresh.
Admin pages also stop trusting the account they mounted with:
Of the two ways to keep the administrator decision off 8000 a stale account, this is the smaller: one hook on the three admin pages, rather than a database read inside every admin policy. The policies still read the role off the actor they are given; every caller other than an open page loads that actor per request.
Notes for review:
Evidence
Before: on
main, the new tests fail — the open page never moves and keeps acting.open_page_access_test.exs: 15 of 19 fail (the 4 that pass assert pages that must be left alone). The admin re-check tests inadmin_live/users_test.exsfail.open_pages_follow_access.feature: 0 of 6. Browseropen_page_access.feature: 0 of 2.After: all pass, including in Chromium, where a page the person may still see is refreshed in place with no extra history entry.
Merge Danger
Door: two-way
No schema or data change; reverting restores the old behaviour.
Blast Radius: sessions