UI & Feature update - Alpha #9

Merged
Mathis merged 22 commits from dev into prod 2026-01-14 22:40:06 +01:00
5 changed files with 39 additions and 8 deletions
Showing only changes of commit 3908989b39 - Show all commits

View File

@@ -68,6 +68,7 @@ export class UsersRepository {
.select({ .select({
uuid: users.uuid, uuid: users.uuid,
username: users.username, username: users.username,
email: users.email,
displayName: users.displayName, displayName: users.displayName,
avatarUrl: users.avatarUrl, avatarUrl: users.avatarUrl,
status: users.status, status: users.status,

View File

@@ -1,3 +1,7 @@
jest.mock("uuid", () => ({
v4: jest.fn(() => "mocked-uuid"),
}));
jest.mock("@noble/post-quantum/ml-kem.js", () => ({ jest.mock("@noble/post-quantum/ml-kem.js", () => ({
ml_kem768: { ml_kem768: {
keygen: jest.fn(), keygen: jest.fn(),
@@ -12,7 +16,11 @@ jest.mock("jose", () => ({
})); }));
import { CACHE_MANAGER } from "@nestjs/cache-manager"; import { CACHE_MANAGER } from "@nestjs/cache-manager";
import { ConfigService } from "@nestjs/config";
import { Test, TestingModule } from "@nestjs/testing"; import { Test, TestingModule } from "@nestjs/testing";
import { RbacService } from "../auth/rbac.service";
import { MediaService } from "../media/media.service";
import { S3Service } from "../s3/s3.service";
import { UsersRepository } from "./repositories/users.repository"; import { UsersRepository } from "./repositories/users.repository";
import { UsersService } from "./users.service"; import { UsersService } from "./users.service";
@@ -39,6 +47,23 @@ describe("UsersService", () => {
del: jest.fn(), del: jest.fn(),
}; };
const mockRbacService = {
getUserRoles: jest.fn(),
};
const mockMediaService = {
scanFile: jest.fn(),
processImage: jest.fn(),
};
const mockS3Service = {
uploadFile: jest.fn(),
};
const mockConfigService = {
get: jest.fn(),
};
beforeEach(async () => { beforeEach(async () => {
jest.clearAllMocks(); jest.clearAllMocks();
@@ -47,6 +72,10 @@ describe("UsersService", () => {
UsersService, UsersService,
{ provide: UsersRepository, useValue: mockUsersRepository }, { provide: UsersRepository, useValue: mockUsersRepository },
{ provide: CACHE_MANAGER, useValue: mockCacheManager }, { provide: CACHE_MANAGER, useValue: mockCacheManager },
{ provide: RbacService, useValue: mockRbacService },
{ provide: MediaService, useValue: mockMediaService },
{ provide: S3Service, useValue: mockS3Service },
{ provide: ConfigService, useValue: mockConfigService },
], ],
}).compile(); }).compile();

View File

@@ -6,6 +6,7 @@ import {
Injectable, Injectable,
Logger, Logger,
} from "@nestjs/common"; } from "@nestjs/common";
import { ConfigService } from "@nestjs/config";
import type { Cache } from "cache-manager"; import type { Cache } from "cache-manager";
import { v4 as uuidv4 } from "uuid"; import { v4 as uuidv4 } from "uuid";
import { RbacService } from "../auth/rbac.service"; import { RbacService } from "../auth/rbac.service";
@@ -27,6 +28,7 @@ export class UsersService {
private readonly rbacService: RbacService, private readonly rbacService: RbacService,
@Inject(MediaService) private readonly mediaService: IMediaService, @Inject(MediaService) private readonly mediaService: IMediaService,
@Inject(S3Service) private readonly s3Service: IStorageService, @Inject(S3Service) private readonly s3Service: IStorageService,
private readonly configService: ConfigService,
) {} ) {}
private async clearUserCache(username?: string) { private async clearUserCache(username?: string) {
@@ -114,9 +116,7 @@ export class UsersService {
} }
if (file.size > 2 * 1024 * 1024) { if (file.size > 2 * 1024 * 1024) {
throw new BadRequestException( throw new BadRequestException("Image trop volumineuse. Limite: 2 Mo.");
"Image trop volumineuse. Limite: 2 Mo.",
);
} }
// 1. Scan Antivirus // 1. Scan Antivirus

View File

@@ -1,8 +1,7 @@
"use client"; "use client";
import { LogIn, User as UserIcon } from "lucide-react"; import { LogIn } from "lucide-react";
import Link from "next/link"; import Link from "next/link";
import * as React from "react";
import { Avatar, AvatarFallback, AvatarImage } from "@/components/ui/avatar"; import { Avatar, AvatarFallback, AvatarImage } from "@/components/ui/avatar";
import { Button } from "@/components/ui/button"; import { Button } from "@/components/ui/button";
import { useAuth } from "@/providers/auth-provider"; import { useAuth } from "@/providers/auth-provider";

View File

@@ -1,11 +1,13 @@
export interface User { export interface User {
id: string; id?: string;
uuid: string;
username: string; username: string;
email: string; email?: string;
displayName?: string; displayName?: string;
avatarUrl?: string; avatarUrl?: string;
bio?: string; bio?: string;
role: "user" | "admin"; role?: "user" | "admin";
status?: "active" | "verification" | "suspended" | "pending" | "deleted";
createdAt: string; createdAt: string;
} }