Added token TTL env variable with default of 2 hours
This commit is contained in:
1 parent
b9419d7379
commit
61a059bf21
2 files changed
+6
-6
No files matched your search
@@ -94,7 +94,7 @@ You can see the designs [here](https://www.figma.com/design/RPSfaw66HjzSwzntKcgD
|
|||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
### Getting Started (Server)
|
### Getting Started (Server) <a id="server"></a>
|
||||||
|
|
||||||
#### <u>Docker Quickstart</u> <a id="docker-quickstart"></a>
|
#### <u>Docker Quickstart</u> <a id="docker-quickstart"></a>
|
||||||
|
|
||||||
@@ -136,7 +136,7 @@ That's it, the server is ready to use.
|
|||||||
Configure the server with the following environmental variables:
|
Configure the server with the following environmental variables:
|
||||||
|
|
||||||
| ENV Variable Name | Required/Optional | Type | Description | Accepted Values |
|
| ENV Variable Name | Required/Optional | Type | Description | Accepted Values |
|
||||||
| -------------------- | ----------------- | --------- | ------------------------------------------------------------------------------------------- | ------------------- |
|
| -------------------- | ----------------- | --------- | ------------------------------------------------------------------------------------------- | ------------------------------------------------ |
|
||||||
| CLIENT_HOST | Required | `string` | Frontend Host | |
|
| CLIENT_HOST | Required | `string` | Frontend Host | |
|
||||||
| JWT_SECRET | Required | `string` | JWT secret | |
|
| JWT_SECRET | Required | `string` | JWT secret | |
|
||||||
| DB_TYPE | Optional | `string` | Specify DB to use | `MongoDB \| FakeDB` |
|
| DB_TYPE | Optional | `string` | Specify DB to use | `MongoDB \| FakeDB` |
|
||||||
@@ -147,6 +147,7 @@ Configure the server with the following environmental variables:
|
|||||||
| LOGIN_PAGE_URL | Required | `string` | Login url to be used in emailing service | |
|
| LOGIN_PAGE_URL | Required | `string` | Login url to be used in emailing service | |
|
||||||
| REDIS_HOST | Required | `string` | Host address for Redis database | |
|
| REDIS_HOST | Required | `string` | Host address for Redis database | |
|
||||||
| REDIS_PORT | Required | `integer` | Port for Redis database | |
|
| REDIS_PORT | Required | `integer` | Port for Redis database | |
|
||||||
|
| TOKEN_TTL | Optional | string | Time for token to live | In vercel/ms format https://github.com/vercel/ms |
|
||||||
|
|
||||||
<br/>
|
<br/>
|
||||||
|
|
||||||
|
|||||||
@@ -26,7 +26,8 @@ const {
|
|||||||
*/
|
*/
|
||||||
const issueToken = (payload) => {
|
const issueToken = (payload) => {
|
||||||
//TODO Add proper expiration date
|
//TODO Add proper expiration date
|
||||||
return jwt.sign(payload, process.env.JWT_SECRET, { expiresIn: "99d" });
|
const tokenTTL = process.env.TOKEN_TTL ? process.env.TOKEN_TTL : "2h";
|
||||||
|
return jwt.sign(payload, process.env.JWT_SECRET, { expiresIn: tokenTTL });
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -223,9 +224,7 @@ const resetPasswordController = async (req, res, next) => {
|
|||||||
try {
|
try {
|
||||||
await newPasswordValidation.validateAsync(req.body);
|
await newPasswordValidation.validateAsync(req.body);
|
||||||
user = await req.db.resetPassword(req, res);
|
user = await req.db.resetPassword(req, res);
|
||||||
res
|
res.status(200).json({
|
||||||
.status(200)
|
|
||||||
.json({
|
|
||||||
success: true,
|
success: true,
|
||||||
msg: successMessages.AUTH_RESET_PASSWORD,
|
msg: successMessages.AUTH_RESET_PASSWORD,
|
||||||
data: user,
|
data: user,
|
||||||
|
|||||||
Reference in new issue
Block a user