mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-09 04:50:59 +00:00
Migration 0293 adds `sessions.acting_as_user_id`. NULL, which is what every session has carried until now, means the browser is acting as the account it signed in as. It is a selector and not an authorization. The resolver joins it against a live grant on every request, so a value stranded here by a grant that has since been revoked or expired confers nothing. Nothing sweeps the column for correctness; the sweeps that exist are housekeeping, so a delegate's browser lands back in its own account instead of on a wall of 403s. ON DELETE SET NULL, not CASCADE. The two ends mean opposite things: deleting the session's owner should take the session with it, which is the existing `user_id` cascade, while deleting the account being acted on must leave the delegate's browser session alive. A cascade on this side would sign a delegate out of their own account because somebody else deleted theirs.