Skip to main content
zerotal

Documentation


Documentation / @zerotal/auth / Guard

Interface: Guard

Defined in: auth/src/guards.ts:29

The common read surface every guard exposes (all async — guards may do I/O). The default web guard adapts the session-based Auth facade; named guards are RequestGuard instances registered via Auth.viaRequest.

Methods

user()

user(): Promise<unknown>

Defined in: auth/src/guards.ts:31

The authenticated user; rejects with UnauthorizedError when there is none.

Returns

Promise<unknown>


userOrNull()

userOrNull(): Promise<unknown>

Defined in: auth/src/guards.ts:33

The authenticated user, or undefined when there is none.

Returns

Promise<unknown>


id()

id(): Promise<string | number | undefined>

Defined in: auth/src/guards.ts:35

The authenticated user's id, or undefined when there is none.

Returns

Promise<string | number | undefined>


check()

check(): Promise<boolean>

Defined in: auth/src/guards.ts:37

true when a user is authenticated on this guard.

Returns

Promise<boolean>


guest()

guest(): Promise<boolean>

Defined in: auth/src/guards.ts:39

true when no user is authenticated on this guard.

Returns

Promise<boolean>