fix(documents-legaux): éviter 500 upload sans utilisateur valide (#126)
Ne plus associer televersePar à un UUID fictif inexistant ; laisser null tant que l’auth n’est pas branchée sur l’endpoint d’upload. Made-with: Cursor
This commit is contained in:
parent
b0594c32e7
commit
d8a81a56ae
@ -101,8 +101,9 @@ export class DocumentsLegauxController {
|
|||||||
throw new BadRequestException('Aucun fichier fourni');
|
throw new BadRequestException('Aucun fichier fourni');
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Récupérer l'ID utilisateur depuis le guard
|
// TODO: Récupérer l'ID utilisateur depuis le guard quand l'auth sera branchée.
|
||||||
const userId = '00000000-0000-0000-0000-000000000000'; // Temporaire
|
// En attendant, on n'associe pas d'utilisateur plutôt que d'envoyer un UUID fictif invalide.
|
||||||
|
const userId: string | null = null;
|
||||||
|
|
||||||
const document = await this.documentsService.uploadNouvelleVersion(
|
const document = await this.documentsService.uploadNouvelleVersion(
|
||||||
uploadDto.type,
|
uploadDto.type,
|
||||||
|
|||||||
@ -43,7 +43,7 @@ export class DocumentsLegauxService {
|
|||||||
async uploadNouvelleVersion(
|
async uploadNouvelleVersion(
|
||||||
type: 'cgu' | 'privacy',
|
type: 'cgu' | 'privacy',
|
||||||
file: Express.Multer.File,
|
file: Express.Multer.File,
|
||||||
userId: string,
|
userId?: string | null,
|
||||||
): Promise<DocumentLegal> {
|
): Promise<DocumentLegal> {
|
||||||
// Validation du type de fichier
|
// Validation du type de fichier
|
||||||
if (file.mimetype !== 'application/pdf') {
|
if (file.mimetype !== 'application/pdf') {
|
||||||
@ -84,7 +84,7 @@ export class DocumentsLegauxService {
|
|||||||
fichier_path: filePath,
|
fichier_path: filePath,
|
||||||
fichier_hash: hash,
|
fichier_hash: hash,
|
||||||
actif: false, // Pas actif par défaut
|
actif: false, // Pas actif par défaut
|
||||||
televersePar: { id: userId } as any,
|
televersePar: userId ? ({ id: userId } as any) : null,
|
||||||
televerseLe: new Date(),
|
televerseLe: new Date(),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user