🚀 Auto-deploy: DBMaker atualizado em 27/07/2026 11:16:09

This commit is contained in:
2026-07-27 11:16:09 +00:00
parent 2f8513127a
commit 32dc2f9aab
5 changed files with 115 additions and 145 deletions
+14
View File
@@ -0,0 +1,14 @@
DO $$
DECLARE
r RECORD;
BEGIN
FOR r IN (SELECT tablename FROM pg_tables WHERE schemaname = 'steelbook')
LOOP
-- Habilitar RLS
EXECUTE 'ALTER TABLE steelbook.' || quote_ident(r.tablename) || ' ENABLE ROW LEVEL SECURITY;';
-- Criar política de permissão global para usuários logados
EXECUTE 'DROP POLICY IF EXISTS "Auth_ALL_' || r.tablename || '" ON steelbook.' || quote_ident(r.tablename) || ';';
EXECUTE 'CREATE POLICY "Auth_ALL_' || r.tablename || '" ON steelbook.' || quote_ident(r.tablename) || ' FOR ALL USING (auth.role() = ''authenticated'');';
END LOOP;
END $$;
+14
View File
@@ -0,0 +1,14 @@
-- 1. Ativar Row Level Security nas tabelas principais
ALTER TABLE steelbook.projetos ENABLE ROW LEVEL SECURITY;
ALTER TABLE steelbook.templates_customizados ENABLE ROW LEVEL SECURITY;
ALTER TABLE steelbook.t_topicos ENABLE ROW LEVEL SECURITY;
-- 2. Criar políticas para permitir apenas usuários autenticados (authenticated)
-- DROP POLICY IF EXISTS "Autenticados podem gerenciar projetos" ON steelbook.projetos;
-- CREATE POLICY "Autenticados podem gerenciar projetos" ON steelbook.projetos
-- FOR ALL USING (auth.role() = 'authenticated');
-- Em vez de FOR ALL, para produção rigorosa pode-se dividir, mas como o app depende do uso direto via painel admin, "ALL" para role authenticated é o mínimo viável seguro hoje.
CREATE POLICY "RLS_Projetos_Auth" ON steelbook.projetos FOR ALL USING (auth.role() = 'authenticated');
CREATE POLICY "RLS_Templates_Auth" ON steelbook.templates_customizados FOR ALL USING (auth.role() = 'authenticated');
CREATE POLICY "RLS_Topicos_Auth" ON steelbook.t_topicos FOR ALL USING (auth.role() = 'authenticated');
-3
View File
@@ -4,7 +4,6 @@ import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
import { Suspense, lazy } from 'react'
import { ThemeProvider } from './contexts/ThemeContext'
import LoadingSpinner from './components/common/LoadingSpinner'
import PasscodeGuard from './components/common/PasscodeGuard'
// Layout
import Layout from './components/layout/Layout'
@@ -43,7 +42,6 @@ function App() {
return (
<ThemeProvider>
<PasscodeGuard>
<QueryClientProvider client={queryClient}>
<BrowserRouter basename="/dashboard" future={{ v7_startTransition: true, v7_relativeSplatPath: true }}>
<Suspense fallback={<div className="flex items-center justify-center h-screen"><LoadingSpinner size="lg" /></div>}>
@@ -74,7 +72,6 @@ function App() {
</Suspense>
</BrowserRouter>
</QueryClientProvider>
</PasscodeGuard>
</ThemeProvider>
)
}
-112
View File
@@ -1,112 +0,0 @@
import { useState, useEffect } from 'react'
import { motion, AnimatePresence } from 'framer-motion'
import { Lock, ChevronRight, AlertCircle } from 'lucide-react'
interface PasscodeGuardProps {
children: React.ReactNode
}
const CORRECT_PASSCODE = '@@Gi05Br;;'
export default function PasscodeGuard({ children }: PasscodeGuardProps) {
const [passcode, setPasscode] = useState('')
const [isAuthenticated, setIsAuthenticated] = useState(false)
const [error, setError] = useState(false)
const [isLoading, setIsLoading] = useState(true)
useEffect(() => {
const saved = localStorage.getItem('app_access_granted')
if (saved === 'true') {
setIsAuthenticated(true)
}
setIsLoading(false)
}, [])
const handleSubmit = (e: React.FormEvent) => {
e.preventDefault()
if (passcode === CORRECT_PASSCODE) {
localStorage.setItem('app_access_granted', 'true')
setIsAuthenticated(true)
setError(false)
} else {
setError(true)
setPasscode('')
// Shake animation effect could be added here
}
}
if (isLoading) return null
if (isAuthenticated) return <>{children}</>
return (
<div className="min-h-screen w-full bg-slate-950 flex items-center justify-center p-4 selection:bg-blue-500/30">
{/* Background Glow */}
<div className="fixed inset-0 overflow-hidden pointer-events-none">
<div className="absolute top-[-10%] left-[-10%] w-[40%] h-[40%] bg-blue-600/10 blur-[120px] rounded-full" />
<div className="absolute bottom-[-10%] right-[-10%] w-[40%] h-[40%] bg-indigo-600/10 blur-[120px] rounded-full" />
</div>
<motion.div
initial={{ opacity: 0, scale: 0.95 }}
animate={{ opacity: 1, scale: 1 }}
className="w-full max-w-md relative z-10"
>
<div className="bg-slate-900/80 backdrop-blur-xl border border-slate-800 rounded-3xl p-8 shadow-2xl shadow-black/50 overflow-hidden group">
<div className="absolute inset-0 bg-gradient-to-tr from-blue-600/5 to-transparent opacity-0 group-hover:opacity-100 transition-opacity duration-700 pointer-events-none" />
<div className="text-center mb-10">
<motion.div
initial={{ rotate: -10 }}
animate={{ rotate: 0 }}
className="inline-flex p-4 bg-blue-600/10 rounded-2xl mb-6 ring-1 ring-blue-500/20 shadow-inner"
>
<Lock className="text-blue-500 w-8 h-8" />
</motion.div>
<h1 className="text-3xl font-extrabold text-white tracking-tight mb-2">Acesso Restrito</h1>
<p className="text-slate-400 font-medium">O aplicativo está em fase de desenvolvimento.</p>
</div>
<form onSubmit={handleSubmit} className="space-y-6">
<div className="relative group/input">
<input
type="password"
placeholder="Insira a senha de acesso"
value={passcode}
onChange={(e) => setPasscode(e.target.value)}
autoFocus
className={`w-full bg-slate-800/50 border ${error ? 'border-red-500/50 ring-2 ring-red-500/10' : 'border-slate-700/50 group-hover/input:border-slate-600 focus:border-blue-500'} h-14 rounded-2xl px-6 outline-none text-white text-lg transition-all duration-300 placeholder:text-slate-600`}
/>
<AnimatePresence>
{error && (
<motion.div
initial={{ opacity: 0, y: -5 }}
animate={{ opacity: 1, y: 0 }}
exit={{ opacity: 0 }}
className="flex items-center gap-2 text-red-500 text-sm mt-3 font-medium px-2"
>
<AlertCircle size={14} />
Senha incorreta
</motion.div>
)}
</AnimatePresence>
</div>
<button
type="submit"
className="w-full h-14 bg-gradient-to-r from-blue-600 to-indigo-600 hover:from-blue-500 hover:to-indigo-500 text-white rounded-2xl font-bold shadow-lg shadow-blue-600/20 active:scale-[0.98] transition-all duration-200 flex items-center justify-center gap-2 group/btn"
>
Entrar no sistema
<ChevronRight className="w-5 h-5 group-hover/btn:translate-x-1 transition-transform" />
</button>
</form>
<div className="mt-8 pt-6 border-t border-slate-800/50 text-center">
<span className="text-xs text-slate-500 font-medium uppercase tracking-[0.2em]">TrackSteel DBMaker v1.0</span>
</div>
</div>
</motion.div>
</div>
)
}
+87 -30
View File
@@ -1,55 +1,112 @@
import { useState } from 'react'
import { useNavigate } from 'react-router-dom'
import { useAuthStore } from '@/lib/store'
import { supabase } from '@/lib/supabase'
import Button from '@/components/common/Button'
import { BeamsBackground } from '@/components/ui/beams-background'
import { AlertCircle, Mail, Lock } from 'lucide-react'
import { motion, AnimatePresence } from 'framer-motion'
export default function Login() {
const navigate = useNavigate()
const setUser = useAuthStore((state) => state.setUser)
const handleSkipLogin = () => {
// Entrar direto sem credenciais
setUser({
id: 'guest-user',
email: 'guest@steelbook.com',
nome_completo: 'Visitante',
} as any)
navigate('/dashboard')
const [email, setEmail] = useState('')
const [password, setPassword] = useState('')
const [loading, setLoading] = useState(false)
const [error, setError] = useState<string | null>(null)
const handleLogin = async (e: React.FormEvent) => {
e.preventDefault()
setLoading(true)
setError(null)
try {
const { data, error } = await supabase.auth.signInWithPassword({
email,
password,
})
if (error) {
throw error
}
if (data.user) {
setUser(data.user)
navigate('/dashboard')
}
} catch (err: any) {
setError(err.message || 'Erro ao realizar login')
} finally {
setLoading(false)
}
}
return (
<BeamsBackground intensity="strong">
<div className="bg-white rounded-lg shadow-2xl p-8 w-full max-w-md">
<div className="bg-white rounded-lg shadow-2xl p-8 w-full max-w-md relative z-10">
<div className="text-center mb-8">
<h1 className="text-3xl font-bold text-primary mb-2">SteelBook</h1>
<p className="text-gray-600">Gestão Inteligente de Databooks</p>
</div>
<div className="space-y-4">
<Button
onClick={handleSkipLogin}
variant="primary"
className="w-full"
>
Entrar
</Button>
<div className="relative">
<div className="absolute inset-0 flex items-center">
<div className="w-full border-t border-gray-300"></div>
</div>
<div className="relative flex justify-center text-sm">
<span className="px-2 bg-white text-gray-500">Modo Desenvolvimento</span>
<form onSubmit={handleLogin} className="space-y-4">
<div className="space-y-1">
<label className="block text-sm font-medium text-gray-700">E-mail</label>
<div className="relative">
<Mail className="absolute left-3 top-1/2 -translate-y-1/2 text-gray-400" size={18} />
<input
type="email"
required
value={email}
onChange={(e) => setEmail(e.target.value)}
className="w-full pl-10 pr-4 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-primary focus:border-transparent bg-gray-50"
placeholder="seu@email.com"
/>
</div>
</div>
<p className="text-xs text-center text-gray-500">
Autenticação desabilitada para desenvolvimento
</p>
</div>
<div className="space-y-1">
<label className="block text-sm font-medium text-gray-700">Senha</label>
<div className="relative">
<Lock className="absolute left-3 top-1/2 -translate-y-1/2 text-gray-400" size={18} />
<input
type="password"
required
value={password}
onChange={(e) => setPassword(e.target.value)}
className="w-full pl-10 pr-4 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-primary focus:border-transparent bg-gray-50"
placeholder="••••••••"
/>
</div>
</div>
<AnimatePresence>
{error && (
<motion.div
initial={{ opacity: 0, y: -5 }}
animate={{ opacity: 1, y: 0 }}
exit={{ opacity: 0 }}
className="flex items-center gap-2 text-red-600 bg-red-50 p-3 rounded-lg text-sm font-medium"
>
<AlertCircle size={16} />
{error}
</motion.div>
)}
</AnimatePresence>
<Button
type="submit"
variant="primary"
className="w-full mt-4"
disabled={loading}
>
{loading ? 'Autenticando...' : 'Entrar'}
</Button>
</form>
<div className="mt-6 text-center text-sm text-gray-600">
<p>Versão 1.0.0 - 2025</p>
<p>Versão 1.0.0 - 2026</p>
</div>
</div>
</BeamsBackground>