UNPKG

@adonisjs/auth

Version:

Official authentication provider for Adonis framework

98 lines (97 loc) 2.78 kB
import { HttpContextContract } from '@ioc:Adonis/Core/HttpContext'; import { AuthContract, AuthManagerContract } from '@ioc:Adonis/Addons/Auth'; /** * Auth class exposes the API to obtain guard instances for a given * HTTP request. */ export declare class Auth implements AuthContract { private manager; private ctx; /** * We keep a per request singleton instances for each instantiated mapping */ private mappingsCache; /** * The default guard is always the one defined inside the config, until * manually overwritten by the user */ defaultGuard: string; constructor(manager: AuthManagerContract, ctx: HttpContextContract); /** * Returns an instance of a named or the default mapping */ use(mapping?: string): any; /** * Guard name for the default mapping */ get name(): any; /** * Reference to the logged in user */ get user(): any; /** * Reference to the default guard config */ get config(): any; /** * Find if the user has been logged out in the current request */ get isLoggedOut(): any; /** * A boolean to know if user is a guest or not. It is * always opposite of [[isLoggedIn]] */ get isGuest(): any; /** * A boolean to know if user is logged in or not */ get isLoggedIn(): any; /** * A boolean to know if user is retrieved by authenticating * the current request or not. */ get isAuthenticated(): any; /** * Whether or not the authentication has been attempted * for the current request */ get authenticationAttempted(): any; /** * Reference to the provider for looking up the user */ get provider(): any; /** * Verify user credentials. */ verifyCredentials(uid: string, password: string): Promise<any>; /** * Attempt to verify user credentials and perform login */ attempt(uid: string, password: string, ...args: any[]): Promise<any>; /** * Login a user without any verification */ login(user: any, ...args: any[]): Promise<any>; /** * Login a user using their id */ loginViaId(id: string | number, ...args: any[]): Promise<any>; /** * Attempts to authenticate the user for the current HTTP request. An exception * is raised when unable to do so */ authenticate(): Promise<any>; /** * Attempts to authenticate the user for the current HTTP request and supresses * exceptions raised by the [[authenticate]] method and returns a boolean */ check(): Promise<any>; /** * Logout user */ logout(...args: any[]): Promise<any>; /** * Serialize toJSON */ toJSON(): any; }