/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.
- Source
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:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
req | req | HTTP request. | ||
res | res | HTTP response. | ||
req.params | Object | Request parameter. | ||
params.user | Object | Requesting user. | ||
params.expiresin | string | <optional> | '8hr' | Time string for token expiration. |
- Source