How quickly should removing an admin role take effect?
After this you can answer: How quickly should removing an admin role take effect?
Say it in 30 seconds
Section titled “Say it in 30 seconds”The deeper answer
Section titled “The deeper answer”The context resolves only the session’s user identifier. The admin middleware then distinguishes missing authentication, a deleted user and a non-admin role. Those become unauthorized or forbidden responses as appropriate. A database error remains an error; it is not permission to continue.
The make-admin service revokes sessions before changing the role and again afterwards. That narrows a concurrent-login window and requires fresh login after a successful promotion. It is still two systems with no shared transaction: a failure after the database update can leave a changed role even though the overall command failed.
For a high-risk demotion, I would discuss checking authorization again inside the protected write transaction or introducing a durable security version. Those are proposed hardening choices, not guarantees the current code provides.
Counter-questions
Section titled “Counter-questions”Why not put the role in the cookie?
What if the account was deleted?
Does checking on every request remove every race?
Where in MiniTickets
Section titled “Where in MiniTickets”Read Rbac, then inspect the api-app piece →.
apps/api/src/trpc/init.ts → isAdminRead this book online: https://book.theversehub.in/