Utility

flitter-auth/middleware/Utility~ Utility

This should be applied globally. Ensures basic things about the request are true. For example, it provides the auth session data and handles auth flow redirects.


Constructor

new Utility()

Extends

Members

(static) services

Defines the services required by this unit.

(private) _di_allow_defer :boolean

If true, the injector will defer the class if the class requests any services that the container is missing. These services are filled in later and added to the prototype and any instances. True by default.

Type:
  • boolean

(private) _di_deferred_instances :Array.<module:flitter-di/src/Injectable~Injectable>

Collection of instances of this class that need to have the deferred service instances injected into them when the deferred services are finally provided.

(private) _di_deferred_services :Array.<string>

List of services that were deferred and not provided at the time of injection.

Type:
  • Array.<string>

Methods

(async) test(req, res, next, argsopt) → {Promise.<void>}

Applies the middleware. Creates an unauthenticated auth session if one doesn't already exist. If the user is authenticated, injects an instance of {module:flitter-auth/model/User~User} into the request as 'request.user'.

Also instantiates a module:flitter-auth/SecurityContext~SecurityContext for the request and injects it as 'request.security'.

If the session has a key_action_key property, the respective module:flitter-auth/model/KeyAction~KeyAction will be inserted into "request.key_action".

Parameters:
Name Type Attributes Description
req express/request

the request

res express/response

the response

next function

the next function in the stack

args object <optional>

optional args

Returns:
Type
Promise.<void>