From f0fdef56e338e0c8de45bc9a334bb7d375ff28a3 Mon Sep 17 00:00:00 2001 From: bender Date: Wed, 11 Mar 2026 20:38:34 +0000 Subject: [PATCH] Update src/app/api/auth/login/route.ts --- src/app/api/auth/login/route.ts | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/app/api/auth/login/route.ts b/src/app/api/auth/login/route.ts index bf81241..064d78c 100644 --- a/src/app/api/auth/login/route.ts +++ b/src/app/api/auth/login/route.ts @@ -1,5 +1,4 @@ import { NextRequest, NextResponse } from 'next/server'; -import { compare } from 'bcryptjs'; // Temporary in-memory user storage (replace with database) const users: Map = new Map(); @@ -25,8 +24,9 @@ export async function POST(request: NextRequest) { ); } - // Compare password - const isPasswordValid = await compare(password, user.password); + // Compare password using simple hash (not production-ready) + const hashedPassword = await hashPassword(password); + const isPasswordValid = hashedPassword === user.password; if (!isPasswordValid) { return NextResponse.json( { message: 'Invalid email or password' }, @@ -56,3 +56,12 @@ export async function POST(request: NextRequest) { ); } } + +// Simple hash function (not secure - for development only) +async function hashPassword(password: string): Promise { + const encoder = new TextEncoder(); + const data = encoder.encode(password); + const hashBuffer = await crypto.subtle.digest('SHA-256', data); + const hashArray = Array.from(new Uint8Array(hashBuffer)); + return hashArray.map(b => b.toString(16).padStart(2, '0')).join(''); +}