Update src/app/api/auth/register/route.ts

This commit is contained in:
2026-03-11 20:38:34 +00:00
parent f0fdef56e3
commit f68ab32eea

View File

@@ -1,5 +1,4 @@
import { NextRequest, NextResponse } from 'next/server';
import { hash } from 'bcryptjs';
// Temporary in-memory user storage (replace with database)
const users: Map<string, any> = new Map();
@@ -31,8 +30,8 @@ export async function POST(request: NextRequest) {
);
}
// Hash password
const hashedPassword = await hash(password, 10);
// Hash password using simple hash (not production-ready)
const hashedPassword = await hashPassword(password);
// Create user
const user = {
@@ -67,3 +66,12 @@ export async function POST(request: NextRequest) {
);
}
}
// Simple hash function (not secure - for development only)
async function hashPassword(password: string): Promise<string> {
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('');
}