Atualiza portal e admin com bloqueio de máquinas desativadas
This commit is contained in:
parent
e5085962e9
commit
630110bf3a
31 changed files with 1756 additions and 244 deletions
|
|
@ -68,12 +68,15 @@ type EnsureCollaboratorAccountParams = {
|
|||
name: string
|
||||
tenantId: string
|
||||
companyId?: string | null
|
||||
role?: "ADMIN" | "MANAGER" | "AGENT" | "COLLABORATOR"
|
||||
}
|
||||
|
||||
export async function ensureCollaboratorAccount(params: EnsureCollaboratorAccountParams) {
|
||||
const normalizedEmail = params.email.trim().toLowerCase()
|
||||
const name = params.name.trim() || normalizedEmail
|
||||
const tenantId = params.tenantId
|
||||
const targetRole = (params.role ?? "COLLABORATOR").toUpperCase() as "ADMIN" | "MANAGER" | "AGENT" | "COLLABORATOR"
|
||||
const authRole = targetRole.toLowerCase()
|
||||
|
||||
const existingAuth = await prisma.authUser.findUnique({ where: { email: normalizedEmail } })
|
||||
const authUser = existingAuth
|
||||
|
|
@ -82,7 +85,7 @@ export async function ensureCollaboratorAccount(params: EnsureCollaboratorAccoun
|
|||
data: {
|
||||
name,
|
||||
tenantId,
|
||||
role: "collaborator",
|
||||
role: authRole,
|
||||
},
|
||||
})
|
||||
: await prisma.authUser.create({
|
||||
|
|
@ -90,7 +93,7 @@ export async function ensureCollaboratorAccount(params: EnsureCollaboratorAccoun
|
|||
email: normalizedEmail,
|
||||
name,
|
||||
tenantId,
|
||||
role: "collaborator",
|
||||
role: authRole,
|
||||
},
|
||||
})
|
||||
|
||||
|
|
@ -117,14 +120,14 @@ export async function ensureCollaboratorAccount(params: EnsureCollaboratorAccoun
|
|||
update: {
|
||||
name,
|
||||
tenantId,
|
||||
role: "COLLABORATOR",
|
||||
role: targetRole,
|
||||
companyId: params.companyId ?? undefined,
|
||||
},
|
||||
create: {
|
||||
email: normalizedEmail,
|
||||
name,
|
||||
tenantId,
|
||||
role: "COLLABORATOR",
|
||||
role: targetRole,
|
||||
companyId: params.companyId ?? undefined,
|
||||
},
|
||||
})
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue