Skip to content

BE-M0-35 · Sessions end on an access change (D37)

ID BE-M0-35 · Level L0 · Pack Pack G1 · The review's schema changes · Run order row 22b · Issue #150

A change to a person's roles or overrides, their own included, ends every session they have in auth.sessions and stamps profiles.access_changed_at (R-ACC-08). public.session_is_current() says whether the caller's login token was issued after that stamp, for proxy.ts to call on every request (R-ACC-48, its apps/web half in FE pack B2, #151). Permissions are still read from the tables on every query, never from the token (R-ACC-49).

This step changes no file: the code arrived with pack G1's pull request. It proves the change on your Mac's local stack.

  • BE-M0-34 is Done, or you run this step on its own after the same block 1.
  • You are in ~/opleet-v2/opleet on main and the local stack is running.

The migration files were edited in place (D11), so the local database is rebuilt, never migrated.

Terminal window
git switch main && git pull
pnpm supabase db reset
Terminal window
pnpm supabase test db supabase/tests/database/13_tenancy_access.test.sql
  • Block 1: "Finished supabase db reset".
  • Block 2: ok on every line, including the four lines that start R-ACC-08 or R-ACC-48, then Files=1, Tests=59 and Result: PASS.
Terminal window
pnpm supabase db query --local "select proname, prosecdef from pg_proc where proname in ('session_is_current', 'end_sessions_on_access_change') order by 1"

Two rows, both t: each runs as its owner, which is what lets the trigger delete from auth.sessions.

  • supabase db reset stops on a migration: paste the file name and the error into #150. Don't edit the file.
  • A test fails: paste the not ok line and the lines under it that start with #. The test's description starts with the rule it proves.
  • "permission denied" or "must be owner" on auth.sessions: stop and paste it. That means a migration can't end sessions on this stack (D37); BE says so on the issue before changing anything.

Nothing to undo: the step changes no file. pnpm supabase db reset rebuilds the local database from main at any time. Never run any part of it against staging or production.

Log each run as a comment on #150: the date, the last lines of block 2, and the check's output.