From 1ab6e1a969f07c98005f1fcddc9c17d2945dfdf8 Mon Sep 17 00:00:00 2001 From: Mathis HERRIOT <197931332+0x485254@users.noreply.github.com> Date: Mon, 9 Feb 2026 11:45:12 +0100 Subject: [PATCH] refactor: adjust imports and streamline code for consistency - Reorganized import statements in multiple files for better readability. - Refined `auth.service` to remove unused `email` variable in `login` function. - Cleaned up whitespace and formatting in `http-exception.filter.spec.ts`. --- backend/src/auth/auth.service.ts | 2 +- backend/src/common/filters/http-exception.filter.spec.ts | 8 +++++--- backend/src/common/filters/http-exception.filter.ts | 2 +- .../common/middlewares/crawler-detection.middleware.ts | 2 +- 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/backend/src/auth/auth.service.ts b/backend/src/auth/auth.service.ts index 72f11d1..d74f428 100644 --- a/backend/src/auth/auth.service.ts +++ b/backend/src/auth/auth.service.ts @@ -105,7 +105,7 @@ export class AuthService { async login(dto: LoginDto, userAgent?: string, ip?: string) { const emailHash = await this.hashingService.hashEmail(dto.email); this.logger.log(`Login attempt for email hash: ${emailHash}`); - const { email, password } = dto; + const { password } = dto; const user = await this.usersService.findByEmailHash(emailHash); if (!user) { diff --git a/backend/src/common/filters/http-exception.filter.spec.ts b/backend/src/common/filters/http-exception.filter.spec.ts index 628873b..8e7765c 100644 --- a/backend/src/common/filters/http-exception.filter.spec.ts +++ b/backend/src/common/filters/http-exception.filter.spec.ts @@ -49,9 +49,11 @@ describe("AllExceptionsFilter", () => { filter.catch(exception, mockArgumentsHost); - expect(mockResponse.status).toHaveBeenCalledWith(HttpStatus.INTERNAL_SERVER_ERROR); + expect(mockResponse.status).toHaveBeenCalledWith( + HttpStatus.INTERNAL_SERVER_ERROR, + ); expect(Sentry.withScope).toHaveBeenCalled(); - + // Vérifier que captureException a été appelé (via withScope) expect(Sentry.captureException).toHaveBeenCalledWith(exception); }); @@ -79,7 +81,7 @@ describe("AllExceptionsFilter", () => { filter.catch(exception, mockArgumentsHost); expect(mockResponse.status).toHaveBeenCalledWith(HttpStatus.BAD_REQUEST); - + // L'IP 1.2.3.4 hachée en SHA256 contient un hash de 64 caractères const logCall = loggerSpy.mock.calls[0][0]; expect(logCall).toMatch(/[a-f0-9]{64}/); diff --git a/backend/src/common/filters/http-exception.filter.ts b/backend/src/common/filters/http-exception.filter.ts index 4ca1ecb..cf21963 100644 --- a/backend/src/common/filters/http-exception.filter.ts +++ b/backend/src/common/filters/http-exception.filter.ts @@ -1,3 +1,4 @@ +import { createHash } from "node:crypto"; import { ArgumentsHost, Catch, @@ -6,7 +7,6 @@ import { HttpStatus, Logger, } from "@nestjs/common"; -import { createHash } from "node:crypto"; import * as Sentry from "@sentry/nestjs"; import { Request, Response } from "express"; diff --git a/backend/src/common/middlewares/crawler-detection.middleware.ts b/backend/src/common/middlewares/crawler-detection.middleware.ts index 100c19f..b24a0eb 100644 --- a/backend/src/common/middlewares/crawler-detection.middleware.ts +++ b/backend/src/common/middlewares/crawler-detection.middleware.ts @@ -1,7 +1,7 @@ +import { createHash } from "node:crypto"; import { CACHE_MANAGER } from "@nestjs/cache-manager"; import { Inject, Injectable, Logger, NestMiddleware } from "@nestjs/common"; import type { Cache } from "cache-manager"; -import { createHash } from "node:crypto"; import type { NextFunction, Request, Response } from "express"; @Injectable()