feat: refine admin access management
This commit is contained in:
parent
dded6d1927
commit
a69d37a672
9 changed files with 265 additions and 83 deletions
|
|
@ -15,6 +15,7 @@ const STAFF_ROSTER = [
|
|||
{ email: "julio@rever.com.br", name: "Julio Cesar", role: "AGENT" },
|
||||
{ email: "lorena@rever.com.br", name: "Lorena Magalhães", role: "AGENT" },
|
||||
{ email: "renan.pac@paulicon.com.br", name: "Rever", role: "AGENT" },
|
||||
{ email: "suporte@rever.com.br", name: "Telão", role: "AGENT" },
|
||||
{ email: "thiago.medeiros@rever.com.br", name: "Thiago Medeiros", role: "AGENT" },
|
||||
{ email: "weslei@rever.com.br", name: "Weslei Magalhães", role: "AGENT" },
|
||||
]
|
||||
|
|
|
|||
49
scripts/remove-legacy-demo-users.mjs
Normal file
49
scripts/remove-legacy-demo-users.mjs
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
import "dotenv/config"
|
||||
import { PrismaClient } from "@prisma/client"
|
||||
|
||||
const prisma = new PrismaClient()
|
||||
|
||||
const EMAILS_TO_REMOVE = [
|
||||
"cliente.demo@sistema.dev",
|
||||
"luciana.prado@omnisaude.com.br",
|
||||
"ricardo.matos@omnisaude.com.br",
|
||||
"aline.rezende@atlasengenharia.com.br",
|
||||
"joao.ramos@atlasengenharia.com.br",
|
||||
"fernanda.lima@omnisaude.com.br",
|
||||
"mariana.andrade@atlasengenharia.com.br",
|
||||
"renanzera@gmail.com",
|
||||
].map((email) => email.toLowerCase())
|
||||
|
||||
async function deleteAuthUserByEmail(email) {
|
||||
const authUser = await prisma.authUser.findUnique({
|
||||
where: { email },
|
||||
select: { id: true, email: true },
|
||||
})
|
||||
if (!authUser) {
|
||||
console.log(`ℹ️ Usuário não encontrado, ignorando: ${email}`)
|
||||
return
|
||||
}
|
||||
|
||||
await prisma.authSession.deleteMany({ where: { userId: authUser.id } })
|
||||
await prisma.authAccount.deleteMany({ where: { userId: authUser.id } })
|
||||
await prisma.authInvite.deleteMany({ where: { email } })
|
||||
await prisma.user.deleteMany({ where: { email } })
|
||||
|
||||
await prisma.authUser.delete({ where: { id: authUser.id } })
|
||||
console.log(`🧹 Removido: ${email}`)
|
||||
}
|
||||
|
||||
async function main() {
|
||||
for (const email of EMAILS_TO_REMOVE) {
|
||||
await deleteAuthUserByEmail(email)
|
||||
}
|
||||
}
|
||||
|
||||
main()
|
||||
.catch((error) => {
|
||||
console.error("Falha ao remover usuários legado", error)
|
||||
process.exitCode = 1
|
||||
})
|
||||
.finally(async () => {
|
||||
await prisma.$disconnect()
|
||||
})
|
||||
|
|
@ -29,55 +29,6 @@ const defaultUsers = singleUserFromEnv ?? [
|
|||
role: "admin",
|
||||
tenantId,
|
||||
},
|
||||
{
|
||||
email: "cliente.demo@sistema.dev",
|
||||
password: "cliente123",
|
||||
name: "Cliente Demo",
|
||||
role: "manager",
|
||||
tenantId,
|
||||
},
|
||||
{
|
||||
email: "mariana.andrade@atlasengenharia.com.br",
|
||||
password: "manager123",
|
||||
name: "Mariana Andrade",
|
||||
role: "manager",
|
||||
tenantId,
|
||||
},
|
||||
{
|
||||
email: "fernanda.lima@omnisaude.com.br",
|
||||
password: "manager123",
|
||||
name: "Fernanda Lima",
|
||||
role: "manager",
|
||||
tenantId,
|
||||
},
|
||||
{
|
||||
email: "joao.ramos@atlasengenharia.com.br",
|
||||
password: "cliente123",
|
||||
name: "João Pedro Ramos",
|
||||
role: "manager",
|
||||
tenantId,
|
||||
},
|
||||
{
|
||||
email: "aline.rezende@atlasengenharia.com.br",
|
||||
password: "cliente123",
|
||||
name: "Aline Rezende",
|
||||
role: "manager",
|
||||
tenantId,
|
||||
},
|
||||
{
|
||||
email: "ricardo.matos@omnisaude.com.br",
|
||||
password: "cliente123",
|
||||
name: "Ricardo Matos",
|
||||
role: "manager",
|
||||
tenantId,
|
||||
},
|
||||
{
|
||||
email: "luciana.prado@omnisaude.com.br",
|
||||
password: "cliente123",
|
||||
name: "Luciana Prado",
|
||||
role: "manager",
|
||||
tenantId,
|
||||
},
|
||||
{
|
||||
email: "gabriel.oliveira@rever.com.br",
|
||||
password: "agent123",
|
||||
|
|
@ -120,6 +71,13 @@ const defaultUsers = singleUserFromEnv ?? [
|
|||
role: "agent",
|
||||
tenantId,
|
||||
},
|
||||
{
|
||||
email: "suporte@rever.com.br",
|
||||
password: "agent123",
|
||||
name: "Telão",
|
||||
role: "agent",
|
||||
tenantId,
|
||||
},
|
||||
{
|
||||
email: "thiago.medeiros@rever.com.br",
|
||||
password: "agent123",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue