mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2024-11-25 11:16: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(
|
async createTokenForUser(
|
||||||
user: User,
|
user: User,
|
||||||
identifier: string,
|
identifier: string,
|
||||||
validUntil: TimestampMillis,
|
validUntil: TimestampMillis | undefined,
|
||||||
): Promise<AuthTokenWithSecretDto> {
|
): Promise<AuthTokenWithSecretDto> {
|
||||||
user.authTokens = this.getTokensByUser(user);
|
user.authTokens = this.getTokensByUser(user);
|
||||||
|
|
||||||
|
@ -78,7 +78,7 @@ export class AuthService {
|
||||||
// Tokens can only be valid for a maximum of 2 years
|
// Tokens can only be valid for a maximum of 2 years
|
||||||
const maximumTokenValidity =
|
const maximumTokenValidity =
|
||||||
new Date().getTime() + 2 * 365 * 24 * 60 * 60 * 1000;
|
new Date().getTime() + 2 * 365 * 24 * 60 * 60 * 1000;
|
||||||
if (validUntil === 0 || validUntil > maximumTokenValidity) {
|
if (!validUntil || validUntil === 0 || validUntil > maximumTokenValidity) {
|
||||||
token = AuthToken.create(
|
token = AuthToken.create(
|
||||||
keyId,
|
keyId,
|
||||||
user,
|
user,
|
||||||
|
|
Loading…
Reference in a new issue