diff --git a/Dockerfile b/Dockerfile index d96980a..934c287 100644 --- a/Dockerfile +++ b/Dockerfile @@ -6,7 +6,10 @@ WORKDIR /app FROM base AS deps RUN apk add --no-cache libc6-compat openssl COPY package.json package-lock.json* ./ +COPY prisma ./prisma/ RUN npm install --frozen-lockfile +# Generate Prisma Client with correct binary targets +RUN npx prisma generate # Build stage FROM base AS builder @@ -17,7 +20,6 @@ RUN apk add --no-cache openssl COPY --from=deps /app/node_modules ./node_modules COPY . . ENV NEXT_TELEMETRY_DISABLED=1 -RUN npx prisma generate RUN npm run build # Production stage diff --git a/pages/signin.jsx b/pages/signin.jsx index 6e60df6..f845637 100644 --- a/pages/signin.jsx +++ b/pages/signin.jsx @@ -1,32 +1,35 @@ -import { useState } from 'react' -import { useRouter } from 'next/router' -import { signIn } from 'next-auth/react' +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 [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('') + setError("") setLoading(true) + try { - const result = await signIn('credentials', { - redirect: false, - callbackUrl: '/dashboard', + const result = await signIn("credentials", { username, password, + redirect: false, + callbackUrl: "/dashboard" }) - if (result.error) { - setError(result.error) - } else if (result.status === 'ok') { - router.push('/dashboard') + + if (result?.ok) { + router.push("/dashboard") + router.refresh() + } else { + setError(result?.error || "Erro ao entrar") } } catch (err) { - setError('Authentication error') + setError("Erro de conexão") } finally { setLoading(false) } @@ -36,42 +39,45 @@ export default function SignIn() {
- Não tem conta?{' '} + Não tem conta?{" "} Cadastrar
- {error && ( -