From 5ee9b2a7e8542d5f66dcba7d2c82f15a2a2d1562 Mon Sep 17 00:00:00 2001 From: David Mehren Date: Thu, 29 Apr 2021 15:55:11 +0200 Subject: [PATCH] AuthTokenDto: Make properties consistently optional validUntil and lastUsed already have a IsOptional decorator, this makes the properties themselves also optional Signed-off-by: David Mehren --- src/auth/auth-token.dto.ts | 4 ++-- src/auth/auth.service.spec.ts | 4 ++-- src/auth/auth.service.ts | 2 -- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/auth/auth-token.dto.ts b/src/auth/auth-token.dto.ts index 46af7d6be..bd3ef8970 100644 --- a/src/auth/auth-token.dto.ts +++ b/src/auth/auth-token.dto.ts @@ -15,8 +15,8 @@ export class AuthTokenDto { createdAt: Date; @IsDate() @IsOptional() - validUntil: Date; + validUntil: Date | null; @IsDate() @IsOptional() - lastUsed: Date; + lastUsed: Date | null; } diff --git a/src/auth/auth.service.spec.ts b/src/auth/auth.service.spec.ts index 4240afb4e..b79f7f0bf 100644 --- a/src/auth/auth.service.spec.ts +++ b/src/auth/auth.service.spec.ts @@ -251,7 +251,7 @@ describe('AuthService', () => { }); jest.spyOn(authTokenRepo, 'save').mockImplementationOnce( async (authTokenSaved: AuthToken, _): Promise => { - expect(authTokenSaved.lastUsed).toBeUndefined(); + expect(authTokenSaved.lastUsed).toBeNull(); return authTokenSaved; }, ); @@ -275,7 +275,7 @@ describe('AuthService', () => { }); jest.spyOn(authTokenRepo, 'save').mockImplementationOnce( async (authTokenSaved: AuthToken, _): Promise => { - expect(authTokenSaved.lastUsed).toBeUndefined(); + expect(authTokenSaved.lastUsed).toBeNull(); return authTokenSaved; }, ); diff --git a/src/auth/auth.service.ts b/src/auth/auth.service.ts index d81a8d5c5..76758e680 100644 --- a/src/auth/auth.service.ts +++ b/src/auth/auth.service.ts @@ -181,8 +181,6 @@ export class AuthService { toAuthTokenDto(authToken: AuthToken): AuthTokenDto { const tokenDto: AuthTokenDto = { - lastUsed: null, - validUntil: null, label: authToken.label, keyId: authToken.keyId, createdAt: authToken.createdAt,