Skip to content

Commit

Permalink
Update Auth.js
Browse files Browse the repository at this point in the history
  • Loading branch information
dblythy committed Jan 29, 2025
1 parent a71fd7e commit 7c77d64
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions src/Auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,13 +91,23 @@ const renewSessionIfNeeded = async ({ config, session, sessionToken }) => {
}
throttle.set(sessionToken, true);
try {
const lastUpdated = new Date(session?.updatedAt);
const yesterday = new Date();
yesterday.setDate(yesterday.getDate() - 1);
if (lastUpdated > yesterday || !session) {
return;
if (!session) {
const query = await RestQuery({

Check failure on line 95 in src/Auth.js

View workflow job for this annotation

GitHub Actions / Lint

'RestQuery' is not defined
method: RestQuery.Method.get,

Check failure on line 96 in src/Auth.js

View workflow job for this annotation

GitHub Actions / Lint

'RestQuery' is not defined
config,
auth: master(config),
runBeforeFind: false,
className: '_Session',
restWhere: { sessionToken },
restOptions: { limit: 1 },
});
const { results } = await query.execute();
session = results[0];
}

if (!shouldUpdateSessionExpiry(config, session) || !session) {
return;
}
const expiresAt = config.generateSessionExpiresAt();
await new RestWrite(
config,
Expand Down

0 comments on commit 7c77d64

Please sign in to comment.