refactor: simplify auth routes, remove setup endpoint
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
9b6d8f0555
commit
90407c4f8d
3 changed files with 3 additions and 39 deletions
|
|
@ -15,12 +15,8 @@ export async function POST(request: NextRequest) {
|
|||
return NextResponse.json({ error: result.error }, { status: 401 })
|
||||
}
|
||||
|
||||
return NextResponse.json({
|
||||
success: true,
|
||||
user: { name: result.user.name, email: result.user.email },
|
||||
})
|
||||
} catch (error) {
|
||||
console.error("Login error:", error)
|
||||
return NextResponse.json({ success: true })
|
||||
} catch {
|
||||
return NextResponse.json({ error: "Der opstod en fejl" }, { status: 500 })
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,8 +5,7 @@ export async function POST() {
|
|||
try {
|
||||
await logout()
|
||||
return NextResponse.json({ success: true })
|
||||
} catch (error) {
|
||||
console.error("Logout error:", error)
|
||||
} catch {
|
||||
return NextResponse.json({ error: "Der opstod en fejl" }, { status: 500 })
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,31 +0,0 @@
|
|||
import { NextRequest, NextResponse } from "next/server"
|
||||
import { createUserWithPassword } from "@/lib/auth"
|
||||
import { getUserByEmail } from "@/lib/db"
|
||||
|
||||
// One-time setup endpoint to create initial user
|
||||
// Only works if no users exist yet or for the specific email
|
||||
export async function POST(request: NextRequest) {
|
||||
try {
|
||||
const { email, password, name } = await request.json()
|
||||
|
||||
if (!email || !password || !name) {
|
||||
return NextResponse.json({ error: "Email, password og navn er påkrævet" }, { status: 400 })
|
||||
}
|
||||
|
||||
// Check if user already exists
|
||||
const existingUser = getUserByEmail(email)
|
||||
if (existingUser) {
|
||||
return NextResponse.json({ error: "Bruger findes allerede" }, { status: 409 })
|
||||
}
|
||||
|
||||
const user = await createUserWithPassword(email, password, name)
|
||||
|
||||
return NextResponse.json({
|
||||
success: true,
|
||||
user: { id: user.id, email: user.email, name: user.name },
|
||||
})
|
||||
} catch (error) {
|
||||
console.error("Setup error:", error)
|
||||
return NextResponse.json({ error: "Der opstod en fejl" }, { status: 500 })
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Reference in a new issue