(Feat): More changes
This commit is contained in:
@@ -1,7 +1,13 @@
|
||||
import { Router } from "@oak/oak";
|
||||
import { hash, compare } from "bcrypt";
|
||||
import { hash, compare, genSalt } from "bcrypt";
|
||||
import { db } from "../config/database.ts";
|
||||
import { config } from "../config/env.ts";
|
||||
|
||||
// Helper function to hash password with proper salt generation
|
||||
async function hashPassword(password: string): Promise<string> {
|
||||
const salt = await genSalt(config.BCRYPT_ROUNDS);
|
||||
return await hash(password, salt);
|
||||
}
|
||||
import { authenticateToken, generateToken, getCurrentUser } from "../middleware/auth.ts";
|
||||
import { sanitizeInput, isValidEmail, isStrongPassword } from "../middleware/security.ts";
|
||||
import type { User, LoginRequest, ChangePasswordRequest } from "../types/index.ts";
|
||||
@@ -144,7 +150,7 @@ router.post("/change-password", authenticateToken, async (ctx) => {
|
||||
}
|
||||
|
||||
// Hash new password with configured rounds
|
||||
const hashedPassword = await hash(newPassword, config.BCRYPT_ROUNDS);
|
||||
const hashedPassword = await hashPassword(newPassword);
|
||||
|
||||
// Update password
|
||||
await db.execute(
|
||||
|
||||
Reference in New Issue
Block a user