/user/login

Exports the login method for the /api/user/login route.

Requires

Methods

(inner) login(req, res)

The method will shortcircuit if the fromACL module exports null with a missing ACL configuration.

Requests which require authentication will return the login method if the authentication fails.

The loginBody method will be called if the request has a POST body.

The loginView method will be returned with a message from a failed user validation or if no login post request body is provided.

Parameters:
NameTypeDescription
reqreq

HTTP request.

resres

HTTP response.

Properties
NameTypeAttributesDescription
req.paramsObject

HTTP request parameter.

Properties
NameTypeAttributesDescription
msgstring<optional>

A message string in regards to a failed loging.

userObject<optional>

Mapp User object.

req.bodyObject<optional>

HTTP POST request body.

(async, inner) loginBody(req, res)

A user object will be requested from the ACL.

The method checks for a redirect location on a _redirect cookie.

The login view will be returned if the fromACL() errs.

A user cookie will signed and set as response header.

The response will be redirected to the location from the redirect cookie. The redirect cookie will be removed.

Parameters:
NameTypeDescription
reqreq

HTTP request.

resres

HTTP response.

Properties
NameTypeDescription
req.paramsObject

HTTP request parameter.

req.bodyObject

HTTP POST request body.

(inner) loginView(req, res)

Any existing user cookie for the XYZ instance will be removed [set to null].

A redirect cookie will be set to the response header for a redirect to the location after sucessful login.

The default login_view will be set as template request parameter before the XYZ View API method will be returned.

Parameters:
NameTypeDescription
reqreq

HTTP request.

resres

HTTP response.

Properties
NameTypeDescription
req.paramsObject

HTTP request parameter.