From 6e71363752126e1384d274acbc69413b949a5e44 Mon Sep 17 00:00:00 2001 From: Surbhi-sharma1 Date: Mon, 30 Oct 2023 18:32:41 +0530 Subject: [PATCH] fix(sandbox): fix lint issues fix lint issues GH-1673 --- .../src/repositories/user.repository.ts | 6 ++---- .../src/repositories/user-ext.repository.ts | 6 ++---- .../src/repositories/user.repository.ts | 6 ++---- .../src/repositories/user.repository.ts | 6 ++---- 4 files changed, 8 insertions(+), 16 deletions(-) diff --git a/sandbox/auth-ms-basic-example/src/repositories/user.repository.ts b/sandbox/auth-ms-basic-example/src/repositories/user.repository.ts index 0d6e7f8bdd..f47f6f7f04 100644 --- a/sandbox/auth-ms-basic-example/src/repositories/user.repository.ts +++ b/sandbox/auth-ms-basic-example/src/repositories/user.repository.ts @@ -145,8 +145,7 @@ export class UserRepository extends DefaultSoftCrudRepository< ): Promise { const user = await super.findOne({where: {username}}); const creds = user && (await this.credentials(user.id).get()); - // eslint-disable-next-line - if (!user || user.deleted || !creds || !creds.password) { + if ((!user || user.deleted) ?? !creds?.password) { throw new HttpErrors.Unauthorized(AuthenticateErrorKeys.UserDoesNotExist); } else if (creds.authProvider !== AuthProvider.INTERNAL) { throw new HttpErrors.BadRequest( @@ -188,8 +187,7 @@ export class UserRepository extends DefaultSoftCrudRepository< AuthenticateErrorKeys.PasswordCannotBeChanged, ); } - // eslint-disable-next-line - if (!user || user.deleted || !creds || !creds.password) { + if ((!user || user.deleted) ?? !creds?.password) { throw new HttpErrors.Unauthorized(AuthenticateErrorKeys.UserDoesNotExist); } else if (await bcrypt.compare(newPassword, creds.password)) { throw new HttpErrors.Unauthorized( diff --git a/sandbox/auth-multitenant-example/src/repositories/user-ext.repository.ts b/sandbox/auth-multitenant-example/src/repositories/user-ext.repository.ts index 020da92026..800bebdc88 100644 --- a/sandbox/auth-multitenant-example/src/repositories/user-ext.repository.ts +++ b/sandbox/auth-multitenant-example/src/repositories/user-ext.repository.ts @@ -139,8 +139,7 @@ export class UserExtRepository extends DefaultSoftCrudRepository< async verifyPassword(username: string, password: string): Promise { const user = await super.findOne({where: {username}}); const creds = user && (await this.credentials(user.id).get()); - // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing - if (!user || user.deleted || !creds?.password) { + if ((!user || user.deleted) ?? !creds?.password) { throw new HttpErrors.Unauthorized(AuthenticateErrorKeys.UserDoesNotExist); } else if (!(await bcrypt.compare(password, creds.password))) { throw new HttpErrors.Unauthorized(AuthErrorKeys.InvalidCredentials); @@ -163,8 +162,7 @@ export class UserExtRepository extends DefaultSoftCrudRepository< ): Promise { const user = await super.findOne({where: {username}}); const creds = user && (await this.credentials(user.id).get()); - // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing - if (!user || user.deleted || !creds?.password) { + if ((!user || user.deleted) ?? !creds?.password) { throw new HttpErrors.Unauthorized(AuthenticateErrorKeys.UserDoesNotExist); } else if (!(await bcrypt.compare(password, creds.password))) { throw new HttpErrors.Unauthorized(AuthErrorKeys.WrongPassword); diff --git a/sandbox/telemed-app/backend/authentication-service/src/repositories/user.repository.ts b/sandbox/telemed-app/backend/authentication-service/src/repositories/user.repository.ts index bfe78fc2ce..296b12b659 100644 --- a/sandbox/telemed-app/backend/authentication-service/src/repositories/user.repository.ts +++ b/sandbox/telemed-app/backend/authentication-service/src/repositories/user.repository.ts @@ -167,8 +167,7 @@ export class UserRepository extends AuditRepositoryMixin< ): Promise { const user = await super.findOne({where: {username}}); const creds = user && (await this.credentials(user.id).get()); - // eslint-disable-next-line - if (!user || user.deleted || !creds || !creds.password) { + if ((!user || user.deleted) ?? !creds?.password) { throw new HttpErrors.Unauthorized(AuthenticateErrorKeys.UserDoesNotExist); } else if (creds.authProvider !== AuthProvider.INTERNAL) { throw new HttpErrors.BadRequest( @@ -210,8 +209,7 @@ export class UserRepository extends AuditRepositoryMixin< AuthenticateErrorKeys.PasswordCannotBeChanged, ); } - // eslint-disable-next-line - if (!user || user.deleted || !creds || !creds.password) { + if ((!user || user.deleted) ?? !creds?.password) { throw new HttpErrors.Unauthorized(AuthenticateErrorKeys.UserDoesNotExist); } else if (await bcrypt.compare(newPassword, creds.password)) { throw new HttpErrors.Unauthorized( diff --git a/services/authentication-service/src/repositories/user.repository.ts b/services/authentication-service/src/repositories/user.repository.ts index e60ed783cd..4a860e586a 100644 --- a/services/authentication-service/src/repositories/user.repository.ts +++ b/services/authentication-service/src/repositories/user.repository.ts @@ -165,8 +165,7 @@ export class UserRepository extends DefaultUserModifyCrudRepository< ): Promise { const user = await super.findOne({where: {username}}); const creds = user && (await this.credentials(user.id).get()); - // eslint-disable-next-line - if (!user || user.deleted || !creds || !creds.password) { + if ((!user || user.deleted) ?? !creds?.password) { throw new HttpErrors.Unauthorized(AuthenticateErrorKeys.UserDoesNotExist); } else if (creds.authProvider !== AuthProvider.INTERNAL) { throw new HttpErrors.BadRequest( @@ -208,8 +207,7 @@ export class UserRepository extends DefaultUserModifyCrudRepository< AuthenticateErrorKeys.PasswordCannotBeChanged, ); } - // eslint-disable-next-line - if (!user || user.deleted || !creds || !creds.password) { + if ((!user || user.deleted) ?? !creds?.password) { throw new HttpErrors.Unauthorized(AuthenticateErrorKeys.UserDoesNotExist); } else if (await bcrypt.compare(newPassword, creds.password)) { throw new HttpErrors.Unauthorized(