docs: registrar fluxo do updater e atualizar chaves
This commit is contained in:
parent
206d00700e
commit
b5fd920efd
50 changed files with 980 additions and 93 deletions
|
|
@ -6,10 +6,11 @@ type EnsureMachineAccountParams = {
|
|||
tenantId: string
|
||||
hostname: string
|
||||
machineToken: string
|
||||
persona?: string
|
||||
}
|
||||
|
||||
export async function ensureMachineAccount(params: EnsureMachineAccountParams) {
|
||||
const { machineId, tenantId, hostname, machineToken } = params
|
||||
const { machineId, tenantId, hostname, machineToken, persona } = params
|
||||
const machineEmail = `machine-${machineId}@machines.local`
|
||||
const context = await auth.$context
|
||||
|
||||
|
|
@ -22,12 +23,14 @@ export async function ensureMachineAccount(params: EnsureMachineAccountParams) {
|
|||
name: machineName,
|
||||
tenantId,
|
||||
role: "machine",
|
||||
machinePersona: persona ?? null,
|
||||
},
|
||||
create: {
|
||||
email: machineEmail,
|
||||
name: machineName,
|
||||
role: "machine",
|
||||
tenantId,
|
||||
machinePersona: persona ?? null,
|
||||
},
|
||||
})
|
||||
|
||||
|
|
|
|||
|
|
@ -19,6 +19,11 @@ export type MachineSessionContext = {
|
|||
companyId: Id<"companies"> | null
|
||||
companySlug: string | null
|
||||
metadata: Record<string, unknown> | null
|
||||
persona: string | null
|
||||
assignedUserId: Id<"users"> | null
|
||||
assignedUserEmail: string | null
|
||||
assignedUserName: string | null
|
||||
assignedUserRole: string | null
|
||||
}
|
||||
headers: Headers
|
||||
response: unknown
|
||||
|
|
@ -41,6 +46,7 @@ export async function createMachineSession(machineToken: string, rememberMe = tr
|
|||
tenantId: resolved.machine.tenantId ?? DEFAULT_TENANT_ID,
|
||||
hostname: resolved.machine.hostname,
|
||||
machineToken,
|
||||
persona: (resolved.machine.persona ?? null) ?? undefined,
|
||||
})
|
||||
|
||||
await client.mutation(api.machines.linkAuthAccount, {
|
||||
|
|
@ -73,6 +79,11 @@ export async function createMachineSession(machineToken: string, rememberMe = tr
|
|||
companyId: (resolved.machine.companyId ?? null) as Id<"companies"> | null,
|
||||
companySlug: resolved.machine.companySlug ?? null,
|
||||
metadata: (resolved.machine.metadata ?? null) as Record<string, unknown> | null,
|
||||
persona: (resolved.machine.persona ?? null) as string | null,
|
||||
assignedUserId: (resolved.machine.assignedUserId ?? null) as Id<"users"> | null,
|
||||
assignedUserEmail: resolved.machine.assignedUserEmail ?? null,
|
||||
assignedUserName: resolved.machine.assignedUserName ?? null,
|
||||
assignedUserRole: resolved.machine.assignedUserRole ?? null,
|
||||
},
|
||||
headers: signIn.headers,
|
||||
response: signIn.response,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue