Skip to main content

run_auth

Function run_auth 

Source
pub async fn run_auth(
    state: &AppState,
    resource: &Resource,
    event: AuthEvent,
    request: &HookRequest,
    payload: Value,
) -> Result<Option<Value>, HttpResponse>
Expand description

Run the auth hook bound to event, if the user resource declares one.

Same contract as run: Ok(None) carries on, Ok(Some(value)) is a replacement, Err(response) aborts the request. resource is the resource the endpoint operates on — user for register/login, api_key for key issuance — but the hook is always looked up on the user model, which is the resource the auth endpoints belong to.