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`.
This commit is contained in:
@@ -105,7 +105,7 @@ export class AuthService {
|
|||||||
async login(dto: LoginDto, userAgent?: string, ip?: string) {
|
async login(dto: LoginDto, userAgent?: string, ip?: string) {
|
||||||
const emailHash = await this.hashingService.hashEmail(dto.email);
|
const emailHash = await this.hashingService.hashEmail(dto.email);
|
||||||
this.logger.log(`Login attempt for email hash: ${emailHash}`);
|
this.logger.log(`Login attempt for email hash: ${emailHash}`);
|
||||||
const { email, password } = dto;
|
const { password } = dto;
|
||||||
const user = await this.usersService.findByEmailHash(emailHash);
|
const user = await this.usersService.findByEmailHash(emailHash);
|
||||||
|
|
||||||
if (!user) {
|
if (!user) {
|
||||||
|
|||||||
@@ -49,9 +49,11 @@ describe("AllExceptionsFilter", () => {
|
|||||||
|
|
||||||
filter.catch(exception, mockArgumentsHost);
|
filter.catch(exception, mockArgumentsHost);
|
||||||
|
|
||||||
expect(mockResponse.status).toHaveBeenCalledWith(HttpStatus.INTERNAL_SERVER_ERROR);
|
expect(mockResponse.status).toHaveBeenCalledWith(
|
||||||
|
HttpStatus.INTERNAL_SERVER_ERROR,
|
||||||
|
);
|
||||||
expect(Sentry.withScope).toHaveBeenCalled();
|
expect(Sentry.withScope).toHaveBeenCalled();
|
||||||
|
|
||||||
// Vérifier que captureException a été appelé (via withScope)
|
// Vérifier que captureException a été appelé (via withScope)
|
||||||
expect(Sentry.captureException).toHaveBeenCalledWith(exception);
|
expect(Sentry.captureException).toHaveBeenCalledWith(exception);
|
||||||
});
|
});
|
||||||
@@ -79,7 +81,7 @@ describe("AllExceptionsFilter", () => {
|
|||||||
filter.catch(exception, mockArgumentsHost);
|
filter.catch(exception, mockArgumentsHost);
|
||||||
|
|
||||||
expect(mockResponse.status).toHaveBeenCalledWith(HttpStatus.BAD_REQUEST);
|
expect(mockResponse.status).toHaveBeenCalledWith(HttpStatus.BAD_REQUEST);
|
||||||
|
|
||||||
// L'IP 1.2.3.4 hachée en SHA256 contient un hash de 64 caractères
|
// L'IP 1.2.3.4 hachée en SHA256 contient un hash de 64 caractères
|
||||||
const logCall = loggerSpy.mock.calls[0][0];
|
const logCall = loggerSpy.mock.calls[0][0];
|
||||||
expect(logCall).toMatch(/[a-f0-9]{64}/);
|
expect(logCall).toMatch(/[a-f0-9]{64}/);
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import { createHash } from "node:crypto";
|
||||||
import {
|
import {
|
||||||
ArgumentsHost,
|
ArgumentsHost,
|
||||||
Catch,
|
Catch,
|
||||||
@@ -6,7 +7,6 @@ import {
|
|||||||
HttpStatus,
|
HttpStatus,
|
||||||
Logger,
|
Logger,
|
||||||
} from "@nestjs/common";
|
} from "@nestjs/common";
|
||||||
import { createHash } from "node:crypto";
|
|
||||||
import * as Sentry from "@sentry/nestjs";
|
import * as Sentry from "@sentry/nestjs";
|
||||||
import { Request, Response } from "express";
|
import { Request, Response } from "express";
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
|
import { createHash } from "node:crypto";
|
||||||
import { CACHE_MANAGER } from "@nestjs/cache-manager";
|
import { CACHE_MANAGER } from "@nestjs/cache-manager";
|
||||||
import { Inject, Injectable, Logger, NestMiddleware } from "@nestjs/common";
|
import { Inject, Injectable, Logger, NestMiddleware } from "@nestjs/common";
|
||||||
import type { Cache } from "cache-manager";
|
import type { Cache } from "cache-manager";
|
||||||
import { createHash } from "node:crypto";
|
|
||||||
import type { NextFunction, Request, Response } from "express";
|
import type { NextFunction, Request, Response } from "express";
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
|
|||||||
Reference in New Issue
Block a user