Checkpoint: Correction des erreurs de compilation - Installation de jsonwebtoken, correction des imports, serveur fonctionnel. Migration OAuth vers authentification locale maintenant opérationnelle.
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import bcrypt from "bcrypt";
|
||||
import { sign, verify } from "jsonwebtoken";
|
||||
import jwt from "jsonwebtoken";
|
||||
import { ENV } from "./env";
|
||||
|
||||
const SALT_ROUNDS = 10;
|
||||
@@ -25,7 +25,7 @@ export async function verifyPassword(
|
||||
* Génère un token JWT pour un utilisateur
|
||||
*/
|
||||
export function generateToken(userId: number): string {
|
||||
return sign({ userId }, ENV.jwtSecret, {
|
||||
return jwt.sign({ userId }, ENV.jwtSecret, {
|
||||
expiresIn: "30d",
|
||||
});
|
||||
}
|
||||
@@ -35,7 +35,7 @@ export function generateToken(userId: number): string {
|
||||
*/
|
||||
export function verifyToken(token: string): { userId: number } | null {
|
||||
try {
|
||||
const decoded = verify(token, ENV.jwtSecret) as { userId: number };
|
||||
const decoded = jwt.verify(token, ENV.jwtSecret) as { userId: number };
|
||||
return decoded;
|
||||
} catch {
|
||||
return null;
|
||||
|
||||
Reference in New Issue
Block a user