From e3449f9c8f257da8079f0f1e981ebf2309911e3b Mon Sep 17 00:00:00 2001 From: Jaime Baez Date: Mon, 13 Jun 2022 01:29:10 +0200 Subject: [PATCH] Fix 500 error on login with email not in DB (#212) * Fix 500 error on login with email not in DB * Fix type declarations in ServerInfoDto --- server/apps/immich/src/api-v1/auth/auth.service.ts | 8 ++++++-- .../immich/src/api-v1/server-info/dto/server-info.dto.ts | 6 +++--- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/server/apps/immich/src/api-v1/auth/auth.service.ts b/server/apps/immich/src/api-v1/auth/auth.service.ts index 34a0c478a5..b55fdb7896 100644 --- a/server/apps/immich/src/api-v1/auth/auth.service.ts +++ b/server/apps/immich/src/api-v1/auth/auth.service.ts @@ -17,7 +17,7 @@ export class AuthService { private immichJwtService: ImmichJwtService, ) {} - private async validateUser(loginCredential: LoginCredentialDto): Promise { + private async validateUser(loginCredential: LoginCredentialDto): Promise { const user = await this.userRepository.findOne( { email: loginCredential.email }, { @@ -35,9 +35,13 @@ export class AuthService { }, ); + if (!user) { + return null; + } + const isAuthenticated = await this.validatePassword(user.password, loginCredential.password, user.salt); - if (user && isAuthenticated) { + if (isAuthenticated) { return user; } diff --git a/server/apps/immich/src/api-v1/server-info/dto/server-info.dto.ts b/server/apps/immich/src/api-v1/server-info/dto/server-info.dto.ts index 251126a188..6abdbf58ae 100644 --- a/server/apps/immich/src/api-v1/server-info/dto/server-info.dto.ts +++ b/server/apps/immich/src/api-v1/server-info/dto/server-info.dto.ts @@ -1,7 +1,7 @@ export class ServerInfoDto { - diskSize: String; - diskUse: String; - diskAvailable: String; + diskSize: string; + diskUse: string; + diskAvailable: string; diskSizeRaw: number; diskUseRaw: number; diskAvailableRaw: number;