Garante typing ao associar usuário de máquina
This commit is contained in:
parent
4f6d0265b5
commit
2f47c40894
1 changed files with 11 additions and 3 deletions
|
|
@ -95,14 +95,22 @@ export async function GET(request: NextRequest) {
|
|||
|
||||
if (!ensuredAssignedUserId && context.persona && context.assignedUserEmail) {
|
||||
try {
|
||||
const ensuredUser = (await client.mutation(api.users.ensureUser, {
|
||||
const ensureArgs: Record<string, unknown> = {
|
||||
tenantId: context.tenantId ?? DEFAULT_TENANT_ID,
|
||||
email: context.assignedUserEmail,
|
||||
name: context.assignedUserName ?? context.assignedUserEmail,
|
||||
avatarUrl: undefined,
|
||||
role: (context.assignedUserRole ?? context.persona ?? "collaborator").toUpperCase(),
|
||||
companyId: context.companyId ?? undefined,
|
||||
})) as { _id?: Id<"users">; name?: string | null; role?: string | null } | null
|
||||
}
|
||||
if (context.companyId) {
|
||||
ensureArgs.companyId = context.companyId as Id<"companies">
|
||||
}
|
||||
|
||||
const ensuredUser = (await client.mutation(api.users.ensureUser, ensureArgs)) as {
|
||||
_id?: Id<"users">
|
||||
name?: string | null
|
||||
role?: string | null
|
||||
} | null
|
||||
|
||||
if (ensuredUser?._id) {
|
||||
ensuredAssignedUserId = ensuredUser._id as string
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue