UNPKG

@adonisjs/auth

Version:

Official authentication provider for Adonis framework

48 lines (47 loc) 1.67 kB
import { Exception } from '@poppinss/utils'; import { HttpContextContract } from '@ioc:Adonis/Core/HttpContext'; /** * Exception raised when unable to authenticate user session */ export declare class AuthenticationException extends Exception { guard: string; redirectTo: string; responseText: string; /** * Raise exception with message and redirect url */ constructor(message: string, code: string, guard?: string, redirectTo?: string); /** * Prompts user to enter credentials */ protected respondWithBasicAuthPrompt(ctx: HttpContextContract, realm?: string): void; /** * Send response as an array of errors */ protected respondWithJson(ctx: HttpContextContract): void; /** * Flash error message and redirect the user back */ protected respondWithRedirect(ctx: HttpContextContract): void; /** * Send response as an array of errors formatted as per JSONAPI spec */ protected respondWithJsonAPI(ctx: HttpContextContract): void; /** * Missing session or unable to lookup user from session */ static invalidSession(guard: string): AuthenticationException; /** * Missing/Invalid token or unable to lookup user from the token */ static invalidToken(guard: string): AuthenticationException; /** * Missing or invalid basic auth credentials */ static invalidBasicCredentials(guard: string): AuthenticationException; /** * Self handle exception and attempt to make the best response based * upon the type of request */ handle(_: AuthenticationException, ctx: HttpContextContract): Promise<void>; }