WIP: ajustes Dockerfile, signin e schema.prisma (correção SQLite/Prisma da sessão anterior)
This commit is contained in:
+3
-1
@@ -6,7 +6,10 @@ WORKDIR /app
|
|||||||
FROM base AS deps
|
FROM base AS deps
|
||||||
RUN apk add --no-cache libc6-compat openssl
|
RUN apk add --no-cache libc6-compat openssl
|
||||||
COPY package.json package-lock.json* ./
|
COPY package.json package-lock.json* ./
|
||||||
|
COPY prisma ./prisma/
|
||||||
RUN npm install --frozen-lockfile
|
RUN npm install --frozen-lockfile
|
||||||
|
# Generate Prisma Client with correct binary targets
|
||||||
|
RUN npx prisma generate
|
||||||
|
|
||||||
# Build stage
|
# Build stage
|
||||||
FROM base AS builder
|
FROM base AS builder
|
||||||
@@ -17,7 +20,6 @@ RUN apk add --no-cache openssl
|
|||||||
COPY --from=deps /app/node_modules ./node_modules
|
COPY --from=deps /app/node_modules ./node_modules
|
||||||
COPY . .
|
COPY . .
|
||||||
ENV NEXT_TELEMETRY_DISABLED=1
|
ENV NEXT_TELEMETRY_DISABLED=1
|
||||||
RUN npx prisma generate
|
|
||||||
RUN npm run build
|
RUN npm run build
|
||||||
|
|
||||||
# Production stage
|
# Production stage
|
||||||
|
|||||||
+30
-24
@@ -1,32 +1,35 @@
|
|||||||
import { useState } from 'react'
|
import { useState } from "react"
|
||||||
import { useRouter } from 'next/router'
|
import { useRouter } from "next/router"
|
||||||
import { signIn } from 'next-auth/react'
|
import { signIn } from "next-auth/react"
|
||||||
|
|
||||||
export default function SignIn() {
|
export default function SignIn() {
|
||||||
const [username, setUsername] = useState('')
|
const [username, setUsername] = useState("")
|
||||||
const [password, setPassword] = useState('')
|
const [password, setPassword] = useState("")
|
||||||
const [error, setError] = useState('')
|
const [error, setError] = useState("")
|
||||||
const [loading, setLoading] = useState(false)
|
const [loading, setLoading] = useState(false)
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
|
|
||||||
const handleSubmit = async (e) => {
|
const handleSubmit = async (e) => {
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
setError('')
|
setError("")
|
||||||
setLoading(true)
|
setLoading(true)
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const result = await signIn('credentials', {
|
const result = await signIn("credentials", {
|
||||||
redirect: false,
|
|
||||||
callbackUrl: '/dashboard',
|
|
||||||
username,
|
username,
|
||||||
password,
|
password,
|
||||||
|
redirect: false,
|
||||||
|
callbackUrl: "/dashboard"
|
||||||
})
|
})
|
||||||
if (result.error) {
|
|
||||||
setError(result.error)
|
if (result?.ok) {
|
||||||
} else if (result.status === 'ok') {
|
router.push("/dashboard")
|
||||||
router.push('/dashboard')
|
router.refresh()
|
||||||
|
} else {
|
||||||
|
setError(result?.error || "Erro ao entrar")
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
setError('Authentication error')
|
setError("Erro de conexão")
|
||||||
} finally {
|
} finally {
|
||||||
setLoading(false)
|
setLoading(false)
|
||||||
}
|
}
|
||||||
@@ -36,21 +39,28 @@ export default function SignIn() {
|
|||||||
<div className="min-h-screen bg-gray-50 flex items-center justify-center">
|
<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">
|
<div className="bg-white p-8 rounded-lg shadow-md w-96">
|
||||||
<h2 className="text-2xl font-bold mb-6">Entrar - 1000Apps</h2>
|
<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">
|
<form onSubmit={handleSubmit} className="space-y-4">
|
||||||
<input
|
<input
|
||||||
type="text"
|
type="text"
|
||||||
placeholder="Nome de usuário"
|
placeholder="Nome de usuário"
|
||||||
className="w-full p-2 border rounded"
|
|
||||||
value={username}
|
value={username}
|
||||||
onChange={(e) => setUsername(e.target.value)}
|
onChange={(e) => setUsername(e.target.value)}
|
||||||
|
className="w-full p-2 border rounded"
|
||||||
required
|
required
|
||||||
/>
|
/>
|
||||||
<input
|
<input
|
||||||
type="password"
|
type="password"
|
||||||
placeholder="Senha"
|
placeholder="Senha"
|
||||||
className="w-full p-2 border rounded"
|
|
||||||
value={password}
|
value={password}
|
||||||
onChange={(e) => setPassword(e.target.value)}
|
onChange={(e) => setPassword(e.target.value)}
|
||||||
|
className="w-full p-2 border rounded"
|
||||||
required
|
required
|
||||||
/>
|
/>
|
||||||
<button
|
<button
|
||||||
@@ -58,20 +68,16 @@ export default function SignIn() {
|
|||||||
disabled={loading}
|
disabled={loading}
|
||||||
className="w-full bg-blue-600 text-white py-2 rounded-lg disabled:opacity-50"
|
className="w-full bg-blue-600 text-white py-2 rounded-lg disabled:opacity-50"
|
||||||
>
|
>
|
||||||
{loading ? 'Entrando...' : 'Entrar'}
|
{loading ? "Entrando..." : "Entrar"}
|
||||||
</button>
|
</button>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
<p className="text-center mt-4 text-sm">
|
<p className="text-center mt-4 text-sm">
|
||||||
Não tem conta?{' '}
|
Não tem conta?{" "}
|
||||||
<a href="/signup" className="text-blue-600 hover:underline">
|
<a href="/signup" className="text-blue-600 hover:underline">
|
||||||
Cadastrar
|
Cadastrar
|
||||||
</a>
|
</a>
|
||||||
</p>
|
</p>
|
||||||
{error && (
|
|
||||||
<div className="mt-4 bg-red-100 text-red-700 p-3 rounded">
|
|
||||||
{error}
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
generator client {
|
generator client {
|
||||||
provider = "prisma-client-js"
|
provider = "prisma-client-js"
|
||||||
binaryTargets = ["native", "linux-musl-openssl-3.0.x"]
|
binaryTargets = ["linux-musl-openssl-3.0.x"]
|
||||||
}
|
}
|
||||||
|
|
||||||
datasource db {
|
datasource db {
|
||||||
|
|||||||
Reference in New Issue
Block a user