MishkaCmsCore. Accounts. Notifiers. DisconnectLiveSockets
(Mishka CMS Core v0.0.1)
Copy Markdown
View Source
Cuts a user's live sockets after any write that can shrink what they may reach or end their being
signed in at all — see MishkaCmsCore.Accounts.LiveSockets for what "cut" means here.
In the notifier rather than in the actions, because a permission is taken away from the admin form, from a JSON:API request and from in-app code, and all three arrive here. Notifiers run after the transaction commits, so a socket is only cut once the change it is being cut for is real.
What it watches
MishkaCmsCore.Accounts.UserPermission— the grant itself. Every add and every removal writes a row of this join, whichever action onUserasked for it, so watching the join catches the whole class instead of a list of action names that the next action would not be on.MishkaCmsCore.Accounts.User— a destroy, because the account is gone, and an update that writes anything but the address the account signs in with.MishkaCmsCore.Accounts.Permission— renaming one changes whatMishkaCmsCore.Accounts.Checks.AccessPermissionsanswers for everyone holding it, and deleting one takes their grants with it. Who held it is read before the write byMishkaCmsCore.Accounts.Changes.RememberPermissionHolders, because by the time this runs the grant rows of a deleted permission are gone.