mirror of
https://github.com/docmost/docmost.git
synced 2025-11-18 22:01:11 +10:00
fix: use JWT expiry time for cookie duration (#1268)
* Set default jwt expiry to 90 days.
This commit is contained in:
@ -1,5 +1,6 @@
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { ConfigService } from '@nestjs/config';
|
||||
import ms, { StringValue } from 'ms';
|
||||
|
||||
@Injectable()
|
||||
export class EnvironmentService {
|
||||
@ -56,7 +57,18 @@ export class EnvironmentService {
|
||||
}
|
||||
|
||||
getJwtTokenExpiresIn(): string {
|
||||
return this.configService.get<string>('JWT_TOKEN_EXPIRES_IN', '30d');
|
||||
return this.configService.get<string>('JWT_TOKEN_EXPIRES_IN', '90d');
|
||||
}
|
||||
|
||||
getCookieExpiresIn(): Date {
|
||||
const expiresInStr = this.getJwtTokenExpiresIn();
|
||||
let msUntilExpiry: number;
|
||||
try {
|
||||
msUntilExpiry = ms(expiresInStr as StringValue);
|
||||
} catch (err) {
|
||||
msUntilExpiry = ms('90d');
|
||||
}
|
||||
return new Date(Date.now() + msUntilExpiry);
|
||||
}
|
||||
|
||||
getStorageDriver(): string {
|
||||
|
||||
Reference in New Issue
Block a user