UNPKG

@loopback/docs

Version:
55 lines (39 loc) 1.5 kB
--- lang: en title: 'API docs: authentication.authenticationbindings.auth_action' keywords: LoopBack 4.0, LoopBack 4 sidebar: lb4_sidebar permalink: /doc/en/lb4/apidocs.authentication.authenticationbindings.auth_action.html --- <!-- Do not edit this file. It is automatically generated by API Documenter. --> [Home](./index.md) &gt; [@loopback/authentication](./authentication.md) &gt; [AuthenticationBindings](./authentication.authenticationbindings.md) &gt; [AUTH\_ACTION](./authentication.authenticationbindings.auth_action.md) ## AuthenticationBindings.AUTH\_ACTION variable Key used to inject the authentication function into the sequence. <b>Signature:</b> ```typescript AUTH_ACTION: BindingKey<AuthenticateFn> ``` ## Example ```ts class MySequence implements SequenceHandler { constructor( @inject(AuthenticationBindings.AUTH_ACTION) protected authenticateRequest: AuthenticateFn, // ... other sequence action injections ) {} async handle(context: RequestContext) { try { const {request, response} = context; const route = this.findRoute(request); // Authenticate await this.authenticateRequest(request); // Authentication successful, proceed to invoke controller const args = await this.parseParams(request, route); const result = await this.invoke(route, args); this.send(response, result); } catch (err) { this.reject(context, err); } } } ```