/user/token 🎟

Exports the userToken method for the /api/user/token route. A token can be provided as a parameter to provide authentication with the user roles that request the token from the api.

A new token may not be requested from a user authenticated by a token.

Token authentication will never provide admin access.

Requires

  • module:jsonwebtoken
  • module:/utils/processEnv

Methods

(inner) userToken(req, res)

The /api/user/token endpoint requests a jsonwebtoken for the user object.

The encoded user token expires in 8hours and does not carry admin rights.

Parameters:
NameTypeAttributesDefaultDescription
reqreq

HTTP request.

resres

HTTP response.

req.paramsObject

Request parameter.

params.userObject

Requesting user.

params.expiresinstring<optional>
'8hr'

Time string for token expiration.