Added token TTL env variable with default of 2 hours
This commit is contained in:
1 parent
b9419d7379
commit
61a059bf21
2 files changed
+21
-21
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>
|
||||||
|
|
||||||
@@ -135,18 +135,19 @@ 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` |
|
||||||
| DB_CONNECTION_STRING | Required | `string` | Specifies URL for MongoDB Database | |
|
| DB_CONNECTION_STRING | Required | `string` | Specifies URL for MongoDB Database | |
|
||||||
| PORT | Optional | `integer` | Specifies Port for Server | |
|
| PORT | Optional | `integer` | Specifies Port for Server | |
|
||||||
| SENDGRID_API_KEY | Required | `string` | Specifies API KEY for SendGrid email service | |
|
| SENDGRID_API_KEY | Required | `string` | Specifies API KEY for SendGrid email service | |
|
||||||
| SYSTEM_EMAIL_ADDRESS | Required | `string` | Specifies System email to be used in emailing service, must be a verified email by sendgrid | |
|
| SYSTEM_EMAIL_ADDRESS | Required | `string` | Specifies System email to be used in emailing service, must be a verified email by sendgrid | |
|
||||||
| 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,13 +224,11 @@ 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)
|
success: true,
|
||||||
.json({
|
msg: successMessages.AUTH_RESET_PASSWORD,
|
||||||
success: true,
|
data: user,
|
||||||
msg: successMessages.AUTH_RESET_PASSWORD,
|
});
|
||||||
data: user,
|
|
||||||
});
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
error.service = SERVICE_NAME;
|
error.service = SERVICE_NAME;
|
||||||
next(error);
|
next(error);
|
||||||
|
|||||||
Reference in new issue
Block a user