Skip to content

Commit

Permalink
fix(sandbox): fix lint issues
Browse files Browse the repository at this point in the history
fix lint issues

GH-1673
  • Loading branch information
Surbhi-sharma1 committed Oct 30, 2023
1 parent f315a4a commit 6e71363
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,7 @@ export class UserRepository extends DefaultSoftCrudRepository<
): Promise<User> {
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(
Expand Down Expand Up @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,7 @@ export class UserExtRepository extends DefaultSoftCrudRepository<
async verifyPassword(username: string, password: string): Promise<User> {
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);
Expand All @@ -163,8 +162,7 @@ export class UserExtRepository extends DefaultSoftCrudRepository<
): Promise<User> {
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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,8 +167,7 @@ export class UserRepository extends AuditRepositoryMixin<
): Promise<User> {
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(
Expand Down Expand Up @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,7 @@ export class UserRepository extends DefaultUserModifyCrudRepository<
): Promise<User> {
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(
Expand Down Expand Up @@ -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(
Expand Down

0 comments on commit 6e71363

Please sign in to comment.