4 Commits

Author SHA1 Message Date
Mathis HERRIOT
e73ae80fc5 chore: bump version to 1.7.4
All checks were successful
CI/CD Pipeline / Valider backend (push) Successful in 1m35s
CI/CD Pipeline / Valider frontend (push) Successful in 1m41s
CI/CD Pipeline / Valider documentation (push) Successful in 1m46s
CI/CD Pipeline / Déploiement en Production (push) Successful in 5m26s
2026-01-29 14:11:38 +01:00
Mathis HERRIOT
9ccbd2ceb1 refactor: improve formatting, type safety, and component organization
- Adjusted inconsistent formatting for better readability across components and services.
- Enhanced type safety by adding placeholders for ignored error parameters and improving types across services.
- Improved component organization by reordering imports consistently and applying formatting updates in UI components.
2026-01-29 14:11:28 +01:00
Mathis HERRIOT
3edf5cc070 Merge remote-tracking branch 'origin/main' 2026-01-29 14:05:09 +01:00
a4d0c6aa8c feat(auth): enhance validation rules for username and password
- Updated username validation to allow only lowercase letters, numbers, and underscores.
- Strengthened password requirements to include at least 8 characters, one uppercase letter, one lowercase letter, one number, and one special character.
- Adjusted frontend forms and backend DTOs to reflect new validation rules.
2026-01-28 21:48:23 +01:00
15 changed files with 179 additions and 78 deletions

View File

@@ -59,12 +59,28 @@ Pour approfondir vos connaissances techniques sur le projet :
## Comment l'utiliser ?
### Installation locale
### Déploiement en Production
1. Clonez le dépôt.
2. Installez les dépendances avec `pnpm install`.
3. Configurez les variables d'environnement (voir `.env.example`).
4. Lancez les services via Docker ou manuellement.
Le projet est prêt pour la production via Docker Compose.
1. **Prérequis** : Docker et Docker Compose installés.
2. **Variables d'environnement** : Copiez `.env.example` en `.env.prod` et ajustez les valeurs (clés secrètes, hosts, Sentry DSN, etc.).
3. **Lancement** :
```bash
docker-compose -f docker-compose.prod.yml up -d
```
4. **Services inclus** :
- **Frontend** : Next.js en mode standalone optimisé.
- **Backend** : NestJS avec clustering et monitoring Sentry.
- **Caddy** : Gestion automatique du SSL/TLS.
- **ClamAV** : Scan antivirus en temps réel des médias.
- **Redis** : Cache, sessions et limitation de débit (Throttling/Bot detection).
- **MinIO** : Stockage compatible S3.
### Sécurité et Performance
- **Transcodage Auto** : Toutes les images sont converties en WebP et les vidéos en WebM pour minimiser la bande passante.
- **Bot Detection** : Système intégré de détection et de bannissement automatique des crawlers malveillants via Redis.
- **Monitoring** : Tracking d'erreurs et profilage de performance via Sentry (Node.js et Next.js).
### Clés API

View File

@@ -1,6 +1,6 @@
{
"name": "@memegoat/backend",
"version": "1.7.3",
"version": "1.7.4",
"description": "",
"author": "",
"private": true,

View File

@@ -148,7 +148,7 @@ describe("AuthService", () => {
const dto = {
username: "test",
email: "test@example.com",
password: "password",
password: "Password1!",
};
mockHashingService.hashPassword.mockResolvedValue("hashed-password");
mockHashingService.hashEmail.mockResolvedValue("hashed-email");
@@ -165,7 +165,7 @@ describe("AuthService", () => {
describe("login", () => {
it("should login a user", async () => {
const dto = { email: "test@example.com", password: "password" };
const dto = { email: "test@example.com", password: "Password1!" };
const user = {
uuid: "user-id",
username: "test",

View File

@@ -2,6 +2,7 @@ import {
IsEmail,
IsNotEmpty,
IsString,
Matches,
MaxLength,
MinLength,
} from "class-validator";
@@ -10,6 +11,10 @@ export class RegisterDto {
@IsString()
@IsNotEmpty()
@MaxLength(32)
@Matches(/^[a-z0-9_]+$/, {
message:
"username must contain only lowercase letters, numbers, and underscores",
})
username!: string;
@IsString()
@@ -21,5 +26,15 @@ export class RegisterDto {
@IsString()
@MinLength(8)
@Matches(/[A-Z]/, {
message: "password must contain at least one uppercase letter",
})
@Matches(/[a-z]/, {
message: "password must contain at least one lowercase letter",
})
@Matches(/[0-9]/, { message: "password must contain at least one number" })
@Matches(/[^A-Za-z0-9]/, {
message: "password must contain at least one special character",
})
password!: string;
}

View File

@@ -1,6 +1,6 @@
{
"name": "@memegoat/frontend",
"version": "1.7.3",
"version": "1.7.4",
"private": true,
"scripts": {
"dev": "next dev",

View File

@@ -36,7 +36,7 @@ const loginSchema = z.object({
email: z.string().email({ message: "Email invalide" }),
password: z
.string()
.min(6, { message: "Le mot de passe doit faire au moins 6 caractères" }),
.min(8, { message: "Le mot de passe doit faire au moins 8 caractères" }),
});
type LoginFormValues = z.infer<typeof loginSchema>;
@@ -108,7 +108,10 @@ export default function LoginPage() {
</CardHeader>
<CardContent>
{show2fa ? (
<form onSubmit={onOtpSubmit} className="space-y-6 flex flex-col items-center">
<form
onSubmit={onOtpSubmit}
className="space-y-6 flex flex-col items-center"
>
<InputOTP
maxLength={6}
value={otpValue}
@@ -126,7 +129,11 @@ export default function LoginPage() {
<InputOTPSlot index={5} />
</InputOTPGroup>
</InputOTP>
<Button type="submit" className="w-full" disabled={loading || otpValue.length !== 6}>
<Button
type="submit"
className="w-full"
disabled={loading || otpValue.length !== 6}
>
{loading ? "Vérification..." : "Vérifier le code"}
</Button>
<Button

View File

@@ -29,11 +29,27 @@ import { useAuth } from "@/providers/auth-provider";
const registerSchema = z.object({
username: z
.string()
.min(3, { message: "Le pseudo doit faire au moins 3 caractères" }),
.min(3, { message: "Le pseudo doit faire au moins 3 caractères" })
.regex(/^[a-z0-9_]+$/, {
message:
"Le pseudo ne doit contenir que des minuscules, chiffres et underscores",
}),
email: z.string().email({ message: "Email invalide" }),
password: z
.string()
.min(6, { message: "Le mot de passe doit faire au moins 6 caractères" }),
.min(8, { message: "Le mot de passe doit faire au moins 8 caractères" })
.regex(/[A-Z]/, {
message: "Le mot de passe doit contenir au moins une majuscule",
})
.regex(/[a-z]/, {
message: "Le mot de passe doit contenir au moins une minuscule",
})
.regex(/[0-9]/, {
message: "Le mot de passe doit contenir au moins un chiffre",
})
.regex(/[^A-Za-z0-9]/, {
message: "Le mot de passe doit contenir au moins un caractère spécial",
}),
displayName: z.string().optional(),
});
@@ -84,12 +100,25 @@ export default function RegisterPage() {
<CardContent>
<Form {...form}>
<form onSubmit={form.handleSubmit(onSubmit)} className="space-y-4">
<FormField
control={form.control}
name="displayName"
render={({ field }) => (
<FormItem>
<FormLabel>Nom d'affichage (Optionnel)</FormLabel>
<FormControl>
<Input placeholder="Le Roi des Chèvres" {...field} />
</FormControl>
<FormMessage />
</FormItem>
)}
/>
<FormField
control={form.control}
name="username"
render={({ field }) => (
<FormItem>
<FormLabel>Pseudo</FormLabel>
<FormLabel>Pseudo (minuscule)</FormLabel>
<FormControl>
<Input placeholder="supergoat" {...field} />
</FormControl>
@@ -110,19 +139,6 @@ export default function RegisterPage() {
</FormItem>
)}
/>
<FormField
control={form.control}
name="displayName"
render={({ field }) => (
<FormItem>
<FormLabel>Nom d'affichage (Optionnel)</FormLabel>
<FormControl>
<Input placeholder="Le Roi des Chèvres" {...field} />
</FormControl>
<FormMessage />
</FormItem>
)}
/>
<FormField
control={form.control}
name="password"

View File

@@ -1,15 +1,15 @@
"use client";
import { useEffect, useState } from "react";
import { toast } from "sonner";
import {
CheckCircle,
XCircle,
AlertCircle,
MoreHorizontal,
ArrowLeft,
CheckCircle,
MoreHorizontal,
XCircle,
} from "lucide-react";
import Link from "next/link";
import { useCallback, useEffect, useState } from "react";
import { toast } from "sonner";
import { Badge } from "@/components/ui/badge";
import { Button } from "@/components/ui/button";
import {
@@ -34,34 +34,34 @@ import {
TableRow,
} from "@/components/ui/table";
import { adminService } from "@/services/admin.service";
import { ReportStatus, type Report } from "@/services/report.service";
import { type Report, ReportStatus } from "@/services/report.service";
export default function AdminReportsPage() {
const [reports, setReports] = useState<Report[]>([]);
const [loading, setLoading] = useState(true);
const fetchReports = async () => {
const fetchReports = useCallback(async () => {
setLoading(true);
try {
const data = await adminService.getReports();
setReports(data);
} catch (error) {
} catch (_error) {
toast.error("Erreur lors du chargement des signalements.");
} finally {
setLoading(false);
}
};
}, []);
useEffect(() => {
fetchReports();
}, []);
}, [fetchReports]);
const handleUpdateStatus = async (reportId: string, status: ReportStatus) => {
try {
await adminService.updateReportStatus(reportId, status);
toast.success("Statut mis à jour.");
fetchReports();
} catch (error) {
} catch (_error) {
toast.error("Erreur lors de la mise à jour du statut.");
}
};
@@ -128,9 +128,7 @@ export default function AdminReportsPage() {
) : (
reports.map((report) => (
<TableRow key={report.uuid}>
<TableCell>
{report.reporterId.substring(0, 8)}...
</TableCell>
<TableCell>{report.reporterId.substring(0, 8)}...</TableCell>
<TableCell>
{report.contentId ? (
<Link
@@ -188,9 +186,7 @@ export default function AdminReportsPage() {
</DropdownMenuItem>
{report.contentId && (
<DropdownMenuItem asChild>
<Link href={`/meme/${report.contentId}`}>
Voir le contenu
</Link>
<Link href={`/meme/${report.contentId}`}>Voir le contenu</Link>
</DropdownMenuItem>
)}
</DropdownMenuContent>

View File

@@ -3,6 +3,7 @@
import { zodResolver } from "@hookform/resolvers/zod";
import {
AlertTriangle,
Download,
Laptop,
Loader2,
Moon,
@@ -12,7 +13,6 @@ import {
Sun,
Trash2,
User as UserIcon,
Download,
} from "lucide-react";
import { useRouter } from "next/navigation";
import { useTheme } from "next-themes";
@@ -20,6 +20,7 @@ import * as React from "react";
import { useForm } from "react-hook-form";
import { toast } from "sonner";
import * as z from "zod";
import { TwoFactorSetup } from "@/components/two-factor-setup";
import {
AlertDialog,
AlertDialogAction,
@@ -53,7 +54,6 @@ import { Label } from "@/components/ui/label";
import { RadioGroup, RadioGroupItem } from "@/components/ui/radio-group";
import { Spinner } from "@/components/ui/spinner";
import { Textarea } from "@/components/ui/textarea";
import { TwoFactorSetup } from "@/components/two-factor-setup";
import { useAuth } from "@/providers/auth-provider";
import { UserService } from "@/services/user.service";
@@ -326,7 +326,8 @@ export default function SettingsPage() {
<CardTitle>Portabilité des données</CardTitle>
</div>
<CardDescription>
Conformément au RGPD, vous pouvez exporter l'intégralité de vos données rattachées à votre compte.
Conformément au RGPD, vous pouvez exporter l'intégralité de vos données
rattachées à votre compte.
</CardDescription>
</CardHeader>
<CardContent>
@@ -334,7 +335,8 @@ export default function SettingsPage() {
<div className="space-y-1">
<p className="font-bold">Exporter mes données</p>
<p className="text-sm text-muted-foreground">
Téléchargez un fichier JSON contenant votre profil, vos mèmes et vos favoris.
Téléchargez un fichier JSON contenant votre profil, vos mèmes et vos
favoris.
</p>
</div>
<Button

View File

@@ -35,7 +35,6 @@ import { useAuth } from "@/providers/auth-provider";
import { ContentService } from "@/services/content.service";
import { FavoriteService } from "@/services/favorite.service";
import type { Content } from "@/types/content";
import { ReportDialog } from "./report-dialog";
import { UserContentEditDialog } from "./user-content-edit-dialog";
interface ContentCardProps {
@@ -51,7 +50,7 @@ export function ContentCard({ content, onUpdate }: ContentCardProps) {
const [isLiked, setIsLiked] = React.useState(content.isLiked || false);
const [likesCount, setLikesCount] = React.useState(content.favoritesCount);
const [editDialogOpen, setEditDialogOpen] = React.useState(false);
const [reportDialogOpen, setReportDialogOpen] = React.useState(false);
const [_reportDialogOpen, setReportDialogOpen] = React.useState(false);
const isAuthor = user?.uuid === content.authorId;
const isVideo = !content.mimeType.startsWith("image/");

View File

@@ -48,10 +48,12 @@ export function ReportDialog({
reason,
description,
});
toast.success("Signalement envoyé avec succès. Merci de nous aider à maintenir la communauté sûre.");
toast.success(
"Signalement envoyé avec succès. Merci de nous aider à maintenir la communauté sûre.",
);
onOpenChange(false);
setDescription("");
} catch (error) {
} catch (_error) {
toast.error("Erreur lors de l'envoi du signalement.");
} finally {
setIsSubmitting(false);

View File

@@ -1,8 +1,8 @@
"use client";
import { Loader2, Shield, ShieldAlert, ShieldCheck } from "lucide-react";
import { useState } from "react";
import { toast } from "sonner";
import { Shield, ShieldCheck, ShieldAlert, Loader2 } from "lucide-react";
import { Button } from "@/components/ui/button";
import {
Card,
@@ -18,8 +18,8 @@ import {
InputOTPSeparator,
InputOTPSlot,
} from "@/components/ui/input-otp";
import { AuthService } from "@/services/auth.service";
import { useAuth } from "@/providers/auth-provider";
import { AuthService } from "@/services/auth.service";
export function TwoFactorSetup() {
const { user, refreshUser } = useAuth();
@@ -36,7 +36,7 @@ export function TwoFactorSetup() {
setQrCode(data.qrCodeUrl);
setSecret(data.secret);
setStep("setup");
} catch (error) {
} catch (_error) {
toast.error("Erreur lors de la configuration de la 2FA.");
} finally {
setIsLoading(false);
@@ -52,7 +52,7 @@ export function TwoFactorSetup() {
await refreshUser();
setStep("idle");
setOtpValue("");
} catch (error) {
} catch (_error) {
toast.error("Code invalide. Veuillez réessayer.");
} finally {
setIsLoading(false);
@@ -68,14 +68,14 @@ export function TwoFactorSetup() {
await refreshUser();
setStep("idle");
setOtpValue("");
} catch (error) {
} catch (_error) {
toast.error("Code invalide. Veuillez réessayer.");
} finally {
setIsLoading(false);
}
};
// Note: We need a way to know if 2FA is enabled.
// Note: We need a way to know if 2FA is enabled.
// Assuming user object might have twoFactorEnabled property or similar.
// For now, let's assume it's on the user object (we might need to add it to the type).
const isEnabled = (user as any)?.twoFactorEnabled;
@@ -89,7 +89,8 @@ export function TwoFactorSetup() {
<CardTitle>Double Authentification (2FA)</CardTitle>
</div>
<CardDescription>
Ajoutez une couche de sécurité supplémentaire à votre compte en utilisant une application d'authentification.
Ajoutez une couche de sécurité supplémentaire à votre compte en utilisant
une application d'authentification.
</CardDescription>
</CardHeader>
<CardContent>
@@ -101,7 +102,9 @@ export function TwoFactorSetup() {
</div>
<div className="flex-1">
<p className="font-bold">La 2FA est activée</p>
<p className="text-sm text-muted-foreground">Votre compte est protégé par un code temporaire.</p>
<p className="text-sm text-muted-foreground">
Votre compte est protégé par un code temporaire.
</p>
</div>
<Button variant="outline" size="sm" onClick={() => setStep("verify")}>
Désactiver
@@ -114,10 +117,21 @@ export function TwoFactorSetup() {
</div>
<div className="flex-1">
<p className="font-bold">La 2FA n'est pas activée</p>
<p className="text-sm text-muted-foreground">Activez la 2FA pour mieux protéger votre compte.</p>
<p className="text-sm text-muted-foreground">
Activez la 2FA pour mieux protéger votre compte.
</p>
</div>
<Button variant="primary" size="sm" onClick={handleSetup} disabled={isLoading}>
{isLoading ? <Loader2 className="h-4 w-4 animate-spin" /> : "Configurer"}
<Button
variant="default"
size="sm"
onClick={handleSetup}
disabled={isLoading}
>
{isLoading ? (
<Loader2 className="h-4 w-4 animate-spin" />
) : (
"Configurer"
)}
</Button>
</>
)}
@@ -133,7 +147,8 @@ export function TwoFactorSetup() {
<CardHeader>
<CardTitle>Configurer la 2FA</CardTitle>
<CardDescription>
Scannez le QR Code ci-dessous avec votre application d'authentification (Google Authenticator, Authy, etc.).
Scannez le QR Code ci-dessous avec votre application d'authentification
(Google Authenticator, Authy, etc.).
</CardDescription>
</CardHeader>
<CardContent className="flex flex-col items-center gap-6">
@@ -143,13 +158,17 @@ export function TwoFactorSetup() {
</div>
)}
<div className="w-full space-y-2">
<p className="text-sm font-medium text-center">Ou entrez ce code manuellement :</p>
<p className="text-sm font-medium text-center">
Ou entrez ce code manuellement :
</p>
<code className="block p-2 bg-muted text-center rounded text-xs font-mono break-all">
{secret}
</code>
</div>
<div className="flex flex-col items-center gap-4 w-full border-t pt-6">
<p className="text-sm font-medium">Entrez le code à 6 chiffres pour confirmer :</p>
<p className="text-sm font-medium">
Entrez le code à 6 chiffres pour confirmer :
</p>
<InputOTP maxLength={6} value={otpValue} onChange={setOtpValue}>
<InputOTPGroup>
<InputOTPSlot index={0} />
@@ -166,9 +185,18 @@ export function TwoFactorSetup() {
</div>
</CardContent>
<CardFooter className="flex justify-between">
<Button variant="ghost" onClick={() => setStep("idle")}>Annuler</Button>
<Button onClick={handleEnable} disabled={otpValue.length !== 6 || isLoading}>
{isLoading ? <Loader2 className="h-4 w-4 animate-spin" /> : "Activer la 2FA"}
<Button variant="ghost" onClick={() => setStep("idle")}>
Annuler
</Button>
<Button
onClick={handleEnable}
disabled={otpValue.length !== 6 || isLoading}
>
{isLoading ? (
<Loader2 className="h-4 w-4 animate-spin" />
) : (
"Activer la 2FA"
)}
</Button>
</CardFooter>
</Card>
@@ -181,7 +209,8 @@ export function TwoFactorSetup() {
<CardHeader>
<CardTitle>Désactiver la 2FA</CardTitle>
<CardDescription>
Veuillez entrer le code de votre application pour désactiver la double authentification.
Veuillez entrer le code de votre application pour désactiver la double
authentification.
</CardDescription>
</CardHeader>
<CardContent className="flex flex-col items-center gap-6">
@@ -200,9 +229,19 @@ export function TwoFactorSetup() {
</InputOTP>
</CardContent>
<CardFooter className="flex justify-between">
<Button variant="ghost" onClick={() => setStep("idle")}>Annuler</Button>
<Button variant="destructive" onClick={handleDisable} disabled={otpValue.length !== 6 || isLoading}>
{isLoading ? <Loader2 className="h-4 w-4 animate-spin" /> : "Confirmer la désactivation"}
<Button variant="ghost" onClick={() => setStep("idle")}>
Annuler
</Button>
<Button
variant="destructive"
onClick={handleDisable}
disabled={otpValue.length !== 6 || isLoading}
>
{isLoading ? (
<Loader2 className="h-4 w-4 animate-spin" />
) : (
"Confirmer la désactivation"
)}
</Button>
</CardFooter>
</Card>

View File

@@ -18,7 +18,10 @@ export const adminService = {
return response.data;
},
updateReportStatus: async (reportId: string, status: ReportStatus): Promise<void> => {
updateReportStatus: async (
reportId: string,
status: ReportStatus,
): Promise<void> => {
await api.patch(`/reports/${reportId}/status`, { status });
},

View File

@@ -1,5 +1,9 @@
import api from "@/lib/api";
import type { LoginResponse, RegisterPayload, TwoFactorSetupResponse } from "@/types/auth";
import type {
LoginResponse,
RegisterPayload,
TwoFactorSetupResponse,
} from "@/types/auth";
export const AuthService = {
async login(email: string, password: string): Promise<LoginResponse> {
@@ -31,7 +35,9 @@ export const AuthService = {
},
async setup2fa(): Promise<TwoFactorSetupResponse> {
const { data } = await api.post<TwoFactorSetupResponse>("/users/me/2fa/setup");
const { data } = await api.post<TwoFactorSetupResponse>(
"/users/me/2fa/setup",
);
return data;
},

View File

@@ -1,6 +1,6 @@
{
"name": "@memegoat/source",
"version": "1.7.3",
"version": "1.7.4",
"description": "",
"scripts": {
"version:get": "cmake -P version.cmake GET",