/middleware/validateRequestAuth
Requires
- module:{@link
Methods
(inner) loginRedirect(req, res)
The method will shortcircuit with an existing redirect _redirect cookie.
Otherwise the request url will decoded and assigned to a redirect cookie with a short TTL of 60 seconds.
Any existing user cookie will be removed to prevent unauthorized access with an existing cookie.
The redirect cookie is used to redirect the user back to the original requested url after a successful login.
| Name | Type | Description |
|---|---|---|
req | req | HTTP request. |
res | res | HTTP response. |
(async, inner) validateRequestAuth(req, res)
The async validateRequestAuth will wait for the [user/auth]user/auth module to return a user object.
The user object will be assigned as to the req.params.
PRIVATE processes require user auth for all requests. The redirect logic will set the location header to the login page which is either defined by xyzEnv.AUTH_PATH or defaults to /api/user/login.
| Name | Type | Description |
|---|---|---|
req | req | HTTP request. |
res | res | HTTP response. |
| Name | Type | Attributes | Description |
|---|---|---|---|
req.params | Object | The request params which will be parsed by the validateRequestParams method. | |
req.headers | Object | The request headers. | |
headers.authorization | Object | <optional> | The request carries an authorization header. |
req.url | string | The request url. |