isAuthorized

abstract suspend fun isAuthorized(resourceId: String, action: String): Boolean

Refreshes the RBAC policy from the server, then checks whether the logged-in member is authorized to perform action on resourceId.

Kotlin:

val allowed = StytchB2B.rbac.isAuthorized(
resourceId = "documents",
action = "read",
)

iOS:

let allowed = try await StytchB2B.rbac.isAuthorized(resourceId: "documents", action: "read")

React Native:

const allowed = await StytchB2B.rbac.isAuthorized("documents", "read")

Return

true if the member is authorized; false otherwise.

Parameters

resourceId

The ID of the resource to check authorization for.

action

The action to check (e.g. "read", "write", "delete").

Throws

if the coroutine is cancelled.