MishkaCmsCore.Accounts.Changes.RememberPermissionHolders (Mishka CMS Core v0.0.1)

Copy Markdown View Source

Puts the ids of the users holding this permission into the changeset, before the write.

MishkaCmsCore.Accounts.Notifiers.DisconnectLiveSockets cuts their live sockets once the write commits, and by then it can no longer find them on its own: user_permissions declares the permission on_delete: :delete, so a deleted permission takes its grant rows with it inside the database, without an action of its own to notify about. A rename leaves the rows alone but changes what MishkaCmsCore.Accounts.Checks.AccessPermissions answers for every one of them.

Added for every update and every destroy on the resource rather than to the two actions there are today, so an action written later cannot be the one that forgets it.

ONLY A WRITE THAT CHANGES THE ANSWER PAYS FOR IT. AccessPermissions reads nothing of a permission but its name, so correcting a description cannot take anybody's access away — and a permission held by every signed-in account would otherwise cost a read of every grant row inside the transaction and a reconnect for every holder, from a typo fix. The holders are remembered for a destroy, because the rows are about to go, and for an update that writes :name.