Skip to content

Commit

Permalink
refactor: introduce env variable
Browse files Browse the repository at this point in the history
  • Loading branch information
pranavxc committed Apr 4, 2024
1 parent f9c1335 commit cbd331c
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions packages/nocodb/src/models/UserRefreshToken.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
import process from 'process';
import dayjs from 'dayjs';
import Noco from '~/Noco';
import { extractProps } from '~/helpers/extractProps';
import { MetaTable } from '~/utils/globals';
import { parseMetaProp, stringifyMetaProp } from '~/utils/modelUtils';

const NC_REFRESH_TOKEN_EXP_IN_DAYS =
+process.env.NC_REFRESH_TOKEN_EXP_IN_DAYS || 90;

export default class UserRefreshToken {
fk_user_id: string;
token: string;
Expand Down Expand Up @@ -41,7 +45,9 @@ export default class UserRefreshToken {

// set default expiry as 90 days if missing
if (!('expires_at' in insertObj)) {
insertObj.expires_at = dayjs().add(90, 'day').toDate();
insertObj.expires_at = dayjs()
.add(NC_REFRESH_TOKEN_EXP_IN_DAYS, 'day')
.toDate();
}

if ('meta' in insertObj) {
Expand Down Expand Up @@ -69,7 +75,7 @@ export default class UserRefreshToken {
MetaTable.USER_REFRESH_TOKENS,
{
token: newToken,
expires_at: dayjs().add(90, 'day').toDate(),
expires_at: dayjs().add(NC_REFRESH_TOKEN_EXP_IN_DAYS, 'day').toDate(),
},
{
token: oldToken,
Expand Down

1 comment on commit cbd331c

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PR changes have been deployed. Please run the following command to verify:

docker run -d -p 8888:8080 nocodb/nocodb-timely:0.204.9-pr-8179-20240404-0949

Please sign in to comment.