fix: improve role assignment logic and permission handling in dashboard components

This commit is contained in:
2025-10-27 08:41:53 -03:00
parent 2c2b792b4a
commit 6bfc0c2ced
19 changed files with 2105 additions and 118 deletions

View File

@@ -0,0 +1,114 @@
# Script para criar arquivo .env
# Usar: .\criar-env.ps1
Write-Host ""
Write-Host "════════════════════════════════════════════════════════════" -ForegroundColor Cyan
Write-Host " 🔐 CRIAR ARQUIVO .env - SGSE (Convex Local)" -ForegroundColor Cyan
Write-Host "════════════════════════════════════════════════════════════" -ForegroundColor Cyan
Write-Host ""
# Verificar se .env já existe
if (Test-Path ".env") {
Write-Host "⚠️ ATENÇÃO: Arquivo .env já existe!" -ForegroundColor Yellow
Write-Host ""
$resposta = Read-Host "Deseja sobrescrever? (S/N)"
if ($resposta -ne "S" -and $resposta -ne "s") {
Write-Host ""
Write-Host "❌ Operação cancelada. Arquivo .env mantido." -ForegroundColor Red
Write-Host ""
pause
exit
}
}
Write-Host ""
Write-Host "[1/3] Criando arquivo .env..." -ForegroundColor Yellow
$conteudo = @"
#
# CONFIGURAÇÃO DE AMBIENTE - SGSE
#
# Segurança Better Auth
BETTER_AUTH_SECRET=+Nfg4jTxPv1giF5MlmyYTxpU/VkS3QaDOvgSWd+QmbY=
# URL da aplicação
SITE_URL=http://localhost:5173
#
# IMPORTANTE - SEGURANÇA
#
# 1. Este arquivo NÃO deve ser commitado no Git
# 2. Antes de ir para produção, gere um NOVO secret
# 3. Em produção, altere SITE_URL para a URL real
#
"@
try {
$conteudo | Out-File -FilePath ".env" -Encoding UTF8 -NoNewline
Write-Host "✅ Arquivo .env criado com sucesso!" -ForegroundColor Green
} catch {
Write-Host "❌ ERRO ao criar arquivo .env: $_" -ForegroundColor Red
pause
exit 1
}
Write-Host ""
Write-Host "[2/3] Verificando .gitignore..." -ForegroundColor Yellow
if (Test-Path ".gitignore") {
$gitignoreContent = Get-Content ".gitignore" -Raw
if ($gitignoreContent -notmatch "\.env") {
Add-Content -Path ".gitignore" -Value "`n.env`n.env.local`n.env.*.local"
Write-Host "✅ .env adicionado ao .gitignore" -ForegroundColor Green
} else {
Write-Host "✅ .env já está no .gitignore" -ForegroundColor Green
}
} else {
@"
.env
.env.local
.env.*.local
"@ | Out-File -FilePath ".gitignore" -Encoding UTF8
Write-Host "✅ .gitignore criado" -ForegroundColor Green
}
Write-Host ""
Write-Host "[3/3] Resumo da configuração:" -ForegroundColor Yellow
Write-Host ""
Write-Host "┌─────────────────────────────────────────────────────────┐" -ForegroundColor Cyan
Write-Host "│ ✅ Arquivo criado: packages/backend/.env │" -ForegroundColor Cyan
Write-Host "│ │" -ForegroundColor Cyan
Write-Host "│ Variáveis configuradas: │" -ForegroundColor Cyan
Write-Host "│ • BETTER_AUTH_SECRET: Configurado ✅ │" -ForegroundColor Cyan
Write-Host "│ • SITE_URL: http://localhost:5173 ✅ │" -ForegroundColor Cyan
Write-Host "└─────────────────────────────────────────────────────────┘" -ForegroundColor Cyan
Write-Host ""
Write-Host "════════════════════════════════════════════════════════════" -ForegroundColor Cyan
Write-Host " 📋 PRÓXIMOS PASSOS" -ForegroundColor Cyan
Write-Host "════════════════════════════════════════════════════════════" -ForegroundColor Cyan
Write-Host ""
Write-Host "1. Reinicie o servidor Convex:" -ForegroundColor White
Write-Host " > bunx convex dev" -ForegroundColor Gray
Write-Host ""
Write-Host "2. Reinicie o servidor Web (em outro terminal):" -ForegroundColor White
Write-Host " > cd ..\..\apps\web" -ForegroundColor Gray
Write-Host " > bun run dev" -ForegroundColor Gray
Write-Host ""
Write-Host "3. Verifique que as mensagens de erro pararam ✅" -ForegroundColor White
Write-Host ""
Write-Host "════════════════════════════════════════════════════════════" -ForegroundColor Cyan
Write-Host " ⚠️ LEMBRE-SE" -ForegroundColor Cyan
Write-Host "════════════════════════════════════════════════════════════" -ForegroundColor Cyan
Write-Host ""
Write-Host "• NÃO commite o arquivo .env no Git" -ForegroundColor Yellow
Write-Host "• Gere um NOVO secret antes de ir para produção" -ForegroundColor Yellow
Write-Host "• Altere SITE_URL quando for para produção" -ForegroundColor Yellow
Write-Host ""
Write-Host "Pressione qualquer tecla para continuar..." -ForegroundColor Gray
$null = $Host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")