🔧 Fix: bcrypt statt argon2 (kompatibel)
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
import { create, verify, getNumericDate } from "https://deno.land/x/djwt@v3.0.1/mod.ts";
|
import { create, verify, getNumericDate } from "https://deno.land/x/djwt@v3.0.1/mod.ts";
|
||||||
import { hash, verify as verifyHash } from "https://deno.land/x/argon2@v0.9.2/mod.ts";
|
import * as bcrypt from "https://deno.land/x/bcrypt@v0.4.1/mod.ts";
|
||||||
import type { JWTPayload, UserRole } from "../types/index.ts";
|
import type { JWTPayload, UserRole } from "../types/index.ts";
|
||||||
|
|
||||||
const JWT_SECRET = Deno.env.get("JWT_SECRET") || "secu-super-secret-key-change-in-production";
|
const JWT_SECRET = Deno.env.get("JWT_SECRET") || "secu-super-secret-key-change-in-production";
|
||||||
@@ -66,15 +66,15 @@ export async function verifyToken(token: string): Promise<JWTPayload | null> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Hash password with Argon2
|
// Hash password with bcrypt
|
||||||
export async function hashPassword(password: string): Promise<string> {
|
export async function hashPassword(password: string): Promise<string> {
|
||||||
return await hash(password);
|
return await bcrypt.hash(password);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Verify password
|
// Verify password
|
||||||
export async function verifyPassword(password: string, hashedPassword: string): Promise<boolean> {
|
export async function verifyPassword(password: string, hashedPassword: string): Promise<boolean> {
|
||||||
try {
|
try {
|
||||||
return await verifyHash(password, hashedPassword);
|
return await bcrypt.compare(password, hashedPassword);
|
||||||
} catch {
|
} catch {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user