refactor: reorganiza projeto em legacy/ apos remocao de login
- Move paginas de auth (signin, signup, nextauth) para legacy/auth/ - Move Landing Page para legacy/landing/ - Move dashboard.jsx.bak para legacy/ - Adiciona README documentando backup e deps necessarias - Nenhuma rota ativa depende de NextAuth; app abre direto no dashboard - Deps (next-auth, prisma-adapter, bcryptjs) mantidas para nao quebrar backup - Build Next.js validado (10 rotas, sem rotas de auth/landing)
This commit is contained in:
@@ -0,0 +1,9 @@
|
||||
# Auth Legacy
|
||||
|
||||
Arquivos preservados do fluxo de login (NextAuth):
|
||||
|
||||
- `signin.jsx` — tela de login; usa `signIn` de `next-auth/react`
|
||||
- `signup.jsx` — tela de cadastro; faz POST para `/api/auth/register`
|
||||
- `nextauth.js` — configuração do NextAuth (CredentialsProvider + Prisma + bcrypt)
|
||||
|
||||
Nenhum destes é compilado pelo Next.js enquanto estiver fora de `pages/`.
|
||||
@@ -0,0 +1,62 @@
|
||||
// API DE AUTENTICAÇÃO DESATIVADA TEMPORARIAMENTE (2026-07-11)
|
||||
// Arquivo PRESERVADO para reativação futura. Nenhum componente/chamada
|
||||
// ativa depende desta rota após a remoção do fluxo de login.
|
||||
import NextAuth from "next-auth"
|
||||
import CredentialsProvider from "next-auth/providers/credentials"
|
||||
import { PrismaClient } from "@prisma/client"
|
||||
import bcrypt from "bcryptjs"
|
||||
|
||||
const prisma = new PrismaClient()
|
||||
|
||||
export default NextAuth({
|
||||
providers: [
|
||||
CredentialsProvider({
|
||||
name: "Credentials",
|
||||
credentials: {
|
||||
username: { label: "Username", type: "text" },
|
||||
password: { label: "Password", type: "password" }
|
||||
},
|
||||
async authorize(credentials) {
|
||||
if (!credentials?.username || !credentials?.password) return null
|
||||
const user = await prisma.user.findUnique({
|
||||
where: { username: credentials.username }
|
||||
})
|
||||
if (!user) return null
|
||||
const isValid = await bcrypt.compare(credentials.password, user.password)
|
||||
if (!isValid) return null
|
||||
return {
|
||||
id: user.id,
|
||||
username: user.username,
|
||||
email: user.email,
|
||||
name: user.name,
|
||||
// optional: role, image, etc.
|
||||
}
|
||||
}
|
||||
})
|
||||
],
|
||||
secret: process.env.NEXTAUTH_SECRET,
|
||||
session: {
|
||||
strategy: "jwt",
|
||||
maxAge: 30 * 24 * 60 * 60 // 30 days
|
||||
},
|
||||
callbacks: {
|
||||
async jwt({ token, user }) {
|
||||
if (user) {
|
||||
token.id = user.id
|
||||
token.username = user.username
|
||||
token.email = user.email
|
||||
token.name = user.name
|
||||
}
|
||||
return token
|
||||
},
|
||||
async session({ session, token }) {
|
||||
if (token) {
|
||||
session.user.id = token.id
|
||||
session.user.username = token.username
|
||||
session.user.email = token.email
|
||||
session.user.name = token.name
|
||||
}
|
||||
return session
|
||||
}
|
||||
}
|
||||
})
|
||||
@@ -0,0 +1,87 @@
|
||||
// LOGIN DESATIVADO TEMPORARIAMENTE (2026-07-11)
|
||||
// Arquivo PRESERVADO para reativação futura. Nada neste app o referencia
|
||||
// ativamente (sem links, sem SessionProvider, sem getSession).
|
||||
import { useState } from "react"
|
||||
import { useRouter } from "next/router"
|
||||
import { signIn } from "next-auth/react"
|
||||
|
||||
export default function SignIn() {
|
||||
const [username, setUsername] = useState("")
|
||||
const [password, setPassword] = useState("")
|
||||
const [error, setError] = useState("")
|
||||
const [loading, setLoading] = useState(false)
|
||||
const router = useRouter()
|
||||
|
||||
const handleSubmit = async (e) => {
|
||||
e.preventDefault()
|
||||
setError("")
|
||||
setLoading(true)
|
||||
|
||||
try {
|
||||
const result = await signIn("credentials", {
|
||||
username,
|
||||
password,
|
||||
redirect: false,
|
||||
callbackUrl: "/dashboard"
|
||||
})
|
||||
|
||||
if (result?.ok) {
|
||||
router.push("/dashboard")
|
||||
router.refresh()
|
||||
} else {
|
||||
setError(result?.error || "Erro ao entrar")
|
||||
}
|
||||
} catch (err) {
|
||||
setError("Erro de conexão")
|
||||
} finally {
|
||||
setLoading(false)
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="min-h-screen bg-gray-50 flex items-center justify-center">
|
||||
<div className="bg-white p-8 rounded-lg shadow-md w-96">
|
||||
<h2 className="text-2xl font-bold mb-6">Entrar - 1000Apps</h2>
|
||||
|
||||
{error && (
|
||||
<div className="bg-red-100 text-red-700 p-3 rounded mb-4">
|
||||
{error}
|
||||
</div>
|
||||
)}
|
||||
|
||||
<form onSubmit={handleSubmit} className="space-y-4">
|
||||
<input
|
||||
type="text"
|
||||
placeholder="Nome de usuário"
|
||||
value={username}
|
||||
onChange={(e) => setUsername(e.target.value)}
|
||||
className="w-full p-2 border rounded"
|
||||
required
|
||||
/>
|
||||
<input
|
||||
type="password"
|
||||
placeholder="Senha"
|
||||
value={password}
|
||||
onChange={(e) => setPassword(e.target.value)}
|
||||
className="w-full p-2 border rounded"
|
||||
required
|
||||
/>
|
||||
<button
|
||||
type="submit"
|
||||
disabled={loading}
|
||||
className="w-full bg-blue-600 text-white py-2 rounded-lg disabled:opacity-50"
|
||||
>
|
||||
{loading ? "Entrando..." : "Entrar"}
|
||||
</button>
|
||||
</form>
|
||||
|
||||
<p className="text-center mt-4 text-sm">
|
||||
Não tem conta?{" "}
|
||||
<a href="/signup" className="text-blue-600 hover:underline">
|
||||
Cadastrar
|
||||
</a>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,104 @@
|
||||
// CADASTRO DESATIVADO TEMPORARIAMENTE (2026-07-11)
|
||||
// Arquivo PRESERVADO para reativação futura. Não há mais link ativo para cá.
|
||||
import { useState } from "react"
|
||||
import { useRouter } from "next/router"
|
||||
|
||||
export default function SignUp() {
|
||||
const [username, setUsername] = useState("")
|
||||
const [password, setPassword] = useState("")
|
||||
const [confirmPassword, setConfirmPassword] = useState("")
|
||||
const [error, setError] = useState("")
|
||||
const [loading, setLoading] = useState(false)
|
||||
const router = useRouter()
|
||||
|
||||
const handleSubmit = async (e) => {
|
||||
e.preventDefault()
|
||||
setError("")
|
||||
setLoading(true)
|
||||
try {
|
||||
if (password !== confirmPassword) {
|
||||
setError("Senhas não coincidem")
|
||||
return
|
||||
}
|
||||
|
||||
if (password.length < 6) {
|
||||
setError("Senha deve ter pelo menos 6 caracteres")
|
||||
return
|
||||
}
|
||||
|
||||
const res = await fetch("/api/auth/register", {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify({ username, password })
|
||||
})
|
||||
|
||||
const data = await res.json()
|
||||
|
||||
if (res.ok) {
|
||||
router.push("/signin")
|
||||
} else {
|
||||
setError(data.error || "Erro ao cadastrar")
|
||||
}
|
||||
} catch (err) {
|
||||
setError("Erro de conexão")
|
||||
} finally {
|
||||
setLoading(false)
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="min-h-screen bg-gray-50 flex items-center justify-center">
|
||||
<div className="bg-white p-8 rounded-lg shadow-md w-96">
|
||||
<h2 className="text-2xl font-bold mb-6">Cadastrar - 1000Apps</h2>
|
||||
|
||||
{error && (
|
||||
<div className="mb-4 bg-red-100 text-red-700 p-3 rounded">
|
||||
{error}
|
||||
</div>
|
||||
)}
|
||||
|
||||
<form onSubmit={handleSubmit} className="space-y-4">
|
||||
<input
|
||||
type="text"
|
||||
placeholder="Nome de usuário"
|
||||
className="w-full p-2 border rounded"
|
||||
value={username}
|
||||
onChange={(e) => setUsername(e.target.value)}
|
||||
required
|
||||
/>
|
||||
<input
|
||||
type="password"
|
||||
placeholder="Senha"
|
||||
className="w-full p-2 border rounded"
|
||||
value={password}
|
||||
onChange={(e) => setPassword(e.target.value)}
|
||||
required
|
||||
minLength={6}
|
||||
/>
|
||||
<input
|
||||
type="password"
|
||||
placeholder="Confirmar senha"
|
||||
className="w-full p-2 border rounded"
|
||||
value={confirmPassword}
|
||||
onChange={(e) => setConfirmPassword(e.target.value)}
|
||||
required
|
||||
/>
|
||||
<button
|
||||
type="submit"
|
||||
disabled={loading}
|
||||
className="w-full bg-green-600 text-white py-2 rounded-lg disabled:opacity-50"
|
||||
>
|
||||
{loading ? "Cadastrando..." : "Cadastrar"}
|
||||
</button>
|
||||
</form>
|
||||
|
||||
<p className="text-center mt-4 text-sm">
|
||||
Já tem conta?{" "}
|
||||
<a href="/signin" className="text-blue-600 hover:underline">
|
||||
Entrar
|
||||
</a>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user