feat: stabilize admin dashboard, refactor group management, implement PWA, and fix routing
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
const { PrismaClient } = require('@prisma/client')
|
||||
const { PrismaPg } = require('@prisma/adapter-pg')
|
||||
const { Pool } = require('pg')
|
||||
|
||||
const connectionString = "postgresql://admin:secure_master_pass@localhost:5432/xflow_crm_db"
|
||||
const pool = new Pool({ connectionString })
|
||||
const adapter = new PrismaPg(pool)
|
||||
const prisma = new PrismaClient({ adapter })
|
||||
|
||||
async function main() {
|
||||
const admins = ["ormix16@gmail.com", "almalexyz@gmail.com"]
|
||||
|
||||
for (const email of admins) {
|
||||
const username = email.split('@')[0]
|
||||
console.log(`🔧 Setting prefix as username for: ${email}...`)
|
||||
|
||||
const user = await prisma.user.upsert({
|
||||
where: { email },
|
||||
update: {
|
||||
username: username,
|
||||
role: 'admin'
|
||||
},
|
||||
create: {
|
||||
id: `admin-init-${Math.random().toString(36).slice(2, 7)}`,
|
||||
email: email,
|
||||
username: username,
|
||||
password: 'managed-auth',
|
||||
role: 'admin',
|
||||
profile: {
|
||||
create: {
|
||||
displayName: username,
|
||||
avatar: `https://api.dicebear.com/7.x/avataaars/svg?seed=${username}`
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
console.log(`✅ ${email} updated. URL will be: /profile/${user.username}`)
|
||||
}
|
||||
}
|
||||
|
||||
main()
|
||||
.catch(console.error)
|
||||
.finally(async () => {
|
||||
await prisma.$disconnect()
|
||||
await pool.end()
|
||||
})
|
||||
Reference in New Issue
Block a user