mirror of
https://github.com/bluewave-labs/Checkmate.git
synced 2026-01-29 05:09:26 -06:00
Merge pull request #184 from bluewave-labs/feat/token-ttl
Added token TTL env variable with default of 2 hours, resolves #163
This commit is contained in:
27
README.md
27
README.md
@@ -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>
|
||||
|
||||
@@ -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 |
|
||||
|
||||
<br/>
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user