UserOnly

flitter-auth/middleware/UserOnly~ UserOnly

Allows the request to proceed only if there is an authenticated user in the session. Otherwise, redirects the user to the login page of the default provider, storing the target route.


Constructor

new UserOnly()

Extends

Members

(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.<*>}

Redirects the request to a login page if the session is unauthenticated. Stores the originalUrl in the 'session.auth.flow' key.

Parameters:
Name Type Attributes Default Description
req express/request
res express/response
next function
args object <optional>
{}
Returns:
Type
Promise.<*>