mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2024-11-25 03:06:31 -05:00
feat(auth-service): accept undefined validUntil param
The `validUntil` parameter for `createTokenForUser` may be undefined in some usages. As it is easy to add handling for that here, this commit implements it. Signed-off-by: David Mehren <git@herrmehren.de>
This commit is contained in:
parent
a6734cc58f
commit
de952fe3b2
1 changed files with 2 additions and 2 deletions
|
@ -56,7 +56,7 @@ export class AuthService {
|
|||
async createTokenForUser(
|
||||
user: User,
|
||||
identifier: string,
|
||||
validUntil: TimestampMillis,
|
||||
validUntil: TimestampMillis | undefined,
|
||||
): Promise<AuthTokenWithSecretDto> {
|
||||
user.authTokens = this.getTokensByUser(user);
|
||||
|
||||
|
@ -78,7 +78,7 @@ export class AuthService {
|
|||
// Tokens can only be valid for a maximum of 2 years
|
||||
const maximumTokenValidity =
|
||||
new Date().getTime() + 2 * 365 * 24 * 60 * 60 * 1000;
|
||||
if (validUntil === 0 || validUntil > maximumTokenValidity) {
|
||||
if (!validUntil || validUntil === 0 || validUntil > maximumTokenValidity) {
|
||||
token = AuthToken.create(
|
||||
keyId,
|
||||
user,
|
||||
|
|
Loading…
Reference in a new issue