Skip to content

Commit 38c0443

Browse files
authored
Merge pull request #26 from nixopus/feat/byos-lifecycle
feat(auth): insert user_owned provision record on self-hosted registration
2 parents a9bff2b + 8456fa3 commit 38c0443

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

src/auth/user-setup.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,21 @@ async function createMachineBillingEntry(organizationId: string, sshKeyId: strin
7979
}
8080
}
8181

82+
async function createUserOwnedProvisionRecord(userId: string, organizationId: string, sshKeyId: string): Promise<void> {
83+
try {
84+
await db.insert(schema.userProvisionDetails).values({
85+
userId,
86+
organizationId,
87+
sshKeyId,
88+
type: 'user_owned',
89+
step: 'COMPLETED',
90+
});
91+
logger.info({ userId, organizationId, sshKeyId }, 'created user_owned provision record');
92+
} catch (err) {
93+
logger.error({ err, userId, organizationId, sshKeyId }, 'failed to create user_owned provision record');
94+
}
95+
}
96+
8297
async function patchSessionOrganization(userId: string, organizationId: string): Promise<void> {
8398
try {
8499
const result = await db.update(schema.session)
@@ -114,6 +129,7 @@ async function loadSSHCredentials(userId: string, organizationId: string, userEm
114129
try {
115130
const sshKeyId = await createSSHKeyEntry(organizationId, userEmail);
116131
await createMachineBillingEntry(organizationId, sshKeyId);
132+
await createUserOwnedProvisionRecord(userId, organizationId, sshKeyId);
117133
} catch (err) {
118134
logger.error({ err, userEmail, organizationId }, 'failed to create SSH key entry during self-hosted setup');
119135
}

0 commit comments

Comments
 (0)