AuthSession

Manages the client-side authentication session.

Properties

Link copied to clipboard

The current access token, or null if not authenticated.

Link copied to clipboard

The current API key, or null if not configured.

Link copied to clipboard

Whether the user is currently authenticated via token or API key.

Link copied to clipboard
var principal: Principal?

The current principal, or null if not authenticated.

Functions

Link copied to clipboard
context(ctx: PageContext)
fun link(provider: String): Either<Issue, Unit>

Initiates the linking of an OAuth provider to the current account.

Link copied to clipboard
context(ctx: PageContext)
suspend fun login(credentials: UserRequestModel? = null, provider: String? = null): Either<Issue, Unit>

Performs a login request.

Link copied to clipboard
suspend fun logout(): Either<Issue, Unit>

Performs a logout request.

Link copied to clipboard
suspend fun refresh(): Either<Issue, Unit>

Performs a token refresh request, specifically in AuthType.Password.

Link copied to clipboard
suspend fun register(credentials: UserRequestModel): Either<Issue, Unit>

Performs a registration request, specifically in AuthType.Password.

Link copied to clipboard
fun setApiKey(key: String?)

Sets or clears the API key used for authentication.

Link copied to clipboard
suspend fun strength(password: String): Either<Issue, Pair<Int, String?>>

Estimates the strength of a password, specifically in AuthType.Password.