🚀 Initial commit - PDIMaker v1.0.0
Sistema completo de gestão de PDI com: - Autenticação com email/senha e Google OAuth - Workspaces privados isolados - Sistema de convites com código único - Interface profissional com Next.js 14 - Backend NestJS com PostgreSQL - Docker com Nginx e SSL Desenvolvido por Sergio Correa
This commit is contained in:
8
frontend/app/api/auth/[...nextauth]/route.ts
Normal file
8
frontend/app/api/auth/[...nextauth]/route.ts
Normal file
@@ -0,0 +1,8 @@
|
||||
// app/api/auth/[...nextauth]/route.ts
|
||||
import NextAuth from "next-auth"
|
||||
import { authOptions } from "@/lib/auth/config"
|
||||
|
||||
const handler = NextAuth(authOptions)
|
||||
|
||||
export { handler as GET, handler as POST }
|
||||
|
||||
15
frontend/app/api/auth/logout/route.ts
Normal file
15
frontend/app/api/auth/logout/route.ts
Normal file
@@ -0,0 +1,15 @@
|
||||
// app/api/auth/logout/route.ts
|
||||
import { NextRequest, NextResponse } from "next/server"
|
||||
|
||||
export async function GET(request: NextRequest) {
|
||||
const response = NextResponse.redirect(new URL("/login", request.url))
|
||||
|
||||
// Limpar todos os cookies de autenticação
|
||||
response.cookies.delete("next-auth.session-token")
|
||||
response.cookies.delete("__Secure-next-auth.session-token")
|
||||
response.cookies.delete("next-auth.csrf-token")
|
||||
response.cookies.delete("__Host-next-auth.csrf-token")
|
||||
|
||||
return response
|
||||
}
|
||||
|
||||
51
frontend/app/api/auth/register/route.ts
Normal file
51
frontend/app/api/auth/register/route.ts
Normal file
@@ -0,0 +1,51 @@
|
||||
// app/api/auth/register/route.ts
|
||||
import { NextRequest, NextResponse } from "next/server"
|
||||
import { createUser } from "@/lib/auth/credentials"
|
||||
|
||||
export async function POST(request: NextRequest) {
|
||||
try {
|
||||
const { email, password, name } = await request.json()
|
||||
|
||||
// Validações
|
||||
if (!email || !password || !name) {
|
||||
return NextResponse.json(
|
||||
{ error: "Todos os campos são obrigatórios" },
|
||||
{ status: 400 }
|
||||
)
|
||||
}
|
||||
|
||||
if (password.length < 6) {
|
||||
return NextResponse.json(
|
||||
{ error: "A senha deve ter pelo menos 6 caracteres" },
|
||||
{ status: 400 }
|
||||
)
|
||||
}
|
||||
|
||||
// Criar usuário
|
||||
const user = await createUser(email, password, name)
|
||||
|
||||
return NextResponse.json({
|
||||
success: true,
|
||||
user: {
|
||||
id: user.id,
|
||||
email: user.email,
|
||||
name: user.name
|
||||
}
|
||||
})
|
||||
} catch (error: any) {
|
||||
console.error("Erro ao registrar:", error)
|
||||
|
||||
if (error.message === "Email já cadastrado") {
|
||||
return NextResponse.json(
|
||||
{ error: "Este email já está cadastrado" },
|
||||
{ status: 400 }
|
||||
)
|
||||
}
|
||||
|
||||
return NextResponse.json(
|
||||
{ error: "Erro ao criar conta" },
|
||||
{ status: 500 }
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user