auth/role_grant_queries.ts view source
(deps: QueryDeps, account_id: string, role: string): Promise<boolean> import {query_account_has_active_global_role} from '@fuzdev/fuz_app/auth/role_grant_queries.js'; Like query_account_has_global_role, but only counts the grant when the
account and the granting actor are both active (deleted_at IS NULL).
Used by the last-admin branch of the removability guard: a soft-deleted admin
can't log in and is excluded from query_count_active_accounts_with_global_role,
so the guard must use the same active predicate when testing whether the
*target* is an admin — otherwise removing an already-tombstoned admin is
falsely blocked as cannot_delete_last_admin. Soft-delete does not revoke
role_grant rows (it's reversible), so the actor join filters `deleted_at IS
NULL` too: a grant held only by a tombstoned actor must not keep the account
reading as an admin (the same tombstone-exclusion the acting-actor resolution
applies). The keeper branch deliberately uses the unconditional
query_account_has_global_role (a keeper is never removable regardless of
tombstone state).
deps
query dependencies
account_id
the account to check
stringrole
the role to check for (e.g. ROLE_ADMIN)
stringreturns
Promise<boolean> true if the account is active and any of its actors holds an active global role grant