diff --git a/README.md b/README.md index 876e73495..09f26e237 100644 --- a/README.md +++ b/README.md @@ -94,7 +94,7 @@ You can see the designs [here](https://www.figma.com/design/RPSfaw66HjzSwzntKcgD --- -### Getting Started (Server) +### Getting Started (Server) #### Docker Quickstart @@ -135,18 +135,19 @@ That's it, the server is ready to use. Configure the server with the following environmental variables: -| ENV Variable Name | Required/Optional | Type | Description | Accepted Values | -| -------------------- | ----------------- | --------- | ------------------------------------------------------------------------------------------- | ------------------- | -| CLIENT_HOST | Required | `string` | Frontend Host | | -| JWT_SECRET | Required | `string` | JWT secret | | -| DB_TYPE | Optional | `string` | Specify DB to use | `MongoDB \| FakeDB` | -| DB_CONNECTION_STRING | Required | `string` | Specifies URL for MongoDB Database | | -| PORT | Optional | `integer` | Specifies Port for Server | | -| 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 | | -| LOGIN_PAGE_URL | Required | `string` | Login url to be used in emailing service | | -| REDIS_HOST | Required | `string` | Host address for Redis database | | -| REDIS_PORT | Required | `integer` | Port for Redis database | | +| ENV Variable Name | Required/Optional | Type | Description | Accepted Values | +| -------------------- | ----------------- | --------- | ------------------------------------------------------------------------------------------- | ------------------------------------------------ | +| CLIENT_HOST | Required | `string` | Frontend Host | | +| JWT_SECRET | Required | `string` | JWT secret | | +| DB_TYPE | Optional | `string` | Specify DB to use | `MongoDB \| FakeDB` | +| DB_CONNECTION_STRING | Required | `string` | Specifies URL for MongoDB Database | | +| PORT | Optional | `integer` | Specifies Port for Server | | +| 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 | | +| LOGIN_PAGE_URL | Required | `string` | Login url to be used in emailing service | | +| REDIS_HOST | Required | `string` | Host address 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 |
diff --git a/Server/controllers/authController.js b/Server/controllers/authController.js index 6c23ba404..16eb6eb00 100644 --- a/Server/controllers/authController.js +++ b/Server/controllers/authController.js @@ -26,7 +26,8 @@ const { */ const issueToken = (payload) => { //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 { await newPasswordValidation.validateAsync(req.body); user = await req.db.resetPassword(req, res); - res - .status(200) - .json({ - success: true, - msg: successMessages.AUTH_RESET_PASSWORD, - data: user, - }); + res.status(200).json({ + success: true, + msg: successMessages.AUTH_RESET_PASSWORD, + data: user, + }); } catch (error) { error.service = SERVICE_NAME; next(error);