feat: add user authentication UI to header component

Add login and register dialogs, user dropdown menu with profile link and logout option, and integrate with session management hook. Prevent hydration mismatches by conditionally rendering auth elements after mount. Update package-lock.json with new @esbuild dependencies for build tooling.
This commit is contained in:
Evandro Fonseca Junior committed 2025-11-04 02:33:29 -03:00
1 parent e641138887
commit 55eebde0ba
55 files changed
+7353 -7

No files matched your search

+43
View File
@@ -0,0 +1,43 @@
/**
* Módulo de hash e verificação de senhas
* Usa bcrypt para hashing seguro
*/
import bcrypt from "bcrypt";
const SALT_ROUNDS = 12;
/**
* Gera hash de senha usando bcrypt
* @param password - Senha em texto plano
* @returns Hash da senha
*/
export async function hashPassword(password: string): Promise<string> {
try {
const hash = await bcrypt.hash(password, SALT_ROUNDS);
return hash;
} catch (error) {
console.error("❌ Erro ao gerar hash de senha:", error);
throw new Error("Falha ao processar senha");
}
}
/**
* Compara senha em texto plano com hash
* @param password - Senha em texto plano
* @param hash - Hash armazenado
* @returns true se a senha corresponde, false caso contrário
*/
export async function comparePassword(
password: string,
hash: string
): Promise<boolean> {
try {
const match = await bcrypt.compare(password, hash);
return match;
} catch (error) {
console.error("❌ Erro ao comparar senha:", error);
return false;
}
}