Skip to main content

Function: readOnlyWhileViewingAs()

readOnlyWhileViewingAs(): Promise<{ error: string; ok: false; } | null>

Defined in: src/server/auth/impersonation.ts:41

Guard for contractor (and other) MUTATION server actions: returns a read-only error state while an owner is viewing as another user, else null. Defense-in-depth — getCurrentContractor() already returns null for an impersonating owner (they have no contractor session), so writes can't run as the target; this also covers the rare owner-who-is-also-a-contractor case and gives a clear message.

Returns

Promise<{ error: string; ok: false; } | null>