/user/cookie

Exports the [user] cookie method for the /api/user/cookie route.

Requires

Methods

(async, inner) cookie(req, res)

The cookie method attempts to find a request cookie matching the xyzEnv.TITLE variable.

The cookie will be destroyed [set to NULL] with detroy request parameter truthy.

The cookie method will use the jsonwebtoken library to verify the existing cookie.

If veriffied successfully a new token with updated user credentials will be signed.

The xyzEnv.SECRET variable will be used to sign the token.

The xyzEnv.COOKIE_TTL will be set as time to life for the cookie set on the response header.

The token user will be sent back to the client.

Parameters:
NameTypeDescription
reqreq

HTTP request.

resres

HTTP response.

Properties
NameTypeAttributesDescription
req.cookiesObject<optional>

The request cookies object.

req.params.destroyboolean<optional>

URL parameter flag whether the cookie should be destroyed.

req.params.createboolean<optional>

URL parameter flag whether a new cookie should be created.