/user/redirect

The module exports the default redirect method called from the default or a custom user authentication method.

Requires

Methods

(inner) redirect(req, res, user)

A user object from the acl module is performed with the lookup property flag in the provided user param.

A user cookie is signed with the jsonwebtoken library and set on the response header.

The method checks for a redirect location on the user object or a _redirect cookie and sets the location header to the redirect location or the base directory if no redirect target is found.

The redirect cookie is destroyed [set to NULL] with the response header.

The response is sent with a 302 status code to redirect the client to the location header URL.

Parameters:
NameTypeDescription
reqreq

HTTP request.

resres

HTTP response.

userobject

The user object should contain an email property and optionally a lookup property which will trigger a lookup in the ACL for the user email to assign any additional properties from the ACL to the user object before signing the cookie.

Properties
NameTypeAttributesDescription
user.emailstring

The email property is required to lookup the user in the ACL and assign any additional properties to the user object before signing the cookie.

user.lookupboolean<optional>

The lookup property flag will trigger a lookup in the ACL for the user email to assign any additional properties to the user object before signing the cookie.

user.redirectstring<optional>

Redirect target provided by an authentication flow such as SAML RelayState.