feat: secure convex admin flows with real metrics\n\nCo-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>

This commit is contained in:
esdrasrenan 2025-10-05 19:59:24 -03:00
parent 0ec5b49e8a
commit 29a647f6c6
43 changed files with 4992 additions and 363 deletions

View file

@ -7,7 +7,7 @@ const email = process.env.SEED_USER_EMAIL ?? "admin@sistema.dev"
const password = process.env.SEED_USER_PASSWORD ?? "admin123"
const name = process.env.SEED_USER_NAME ?? "Administrador"
const role = process.env.SEED_USER_ROLE ?? "admin"
const tenantId = process.env.SEED_USER_TENANT ?? "default"
const tenantId = process.env.SEED_USER_TENANT ?? "tenant-atlas"
async function main() {
const hashedPassword = await hashPassword(password)
@ -26,7 +26,7 @@ async function main() {
tenantId,
accounts: {
create: {
providerId: "email",
providerId: "credential",
accountId: email,
password: hashedPassword,
},
@ -37,7 +37,41 @@ async function main() {
},
})
const account = user.accounts[0]
await prisma.authAccount.updateMany({
where: {
userId: user.id,
accountId: email,
},
data: {
providerId: "credential",
},
})
let account = await prisma.authAccount.findFirst({
where: {
userId: user.id,
providerId: "credential",
accountId: email,
},
})
if (account) {
account = await prisma.authAccount.update({
where: { id: account.id },
data: {
password: hashedPassword,
},
})
} else {
account = await prisma.authAccount.create({
data: {
userId: user.id,
providerId: "credential",
accountId: email,
password: hashedPassword,
},
})
}
console.log(`✅ Usuario seed criado/atualizado: ${user.email}`)
console.log(` ID: ${user.id}`)