Option to regenerate Newt keys

This commit is contained in:
Pallavi Kumari
2025-10-26 21:00:46 +05:30
parent 42091e88cb
commit d32505a833
13 changed files with 491 additions and 41 deletions

View File

@@ -32,9 +32,6 @@ const updateClientSchema = z
siteIds: z
.array(z.number().int().positive())
.optional(),
olmId: z.string().min(1).optional(),
secret: z.string().min(1).optional(),
})
.strict();
@@ -79,7 +76,7 @@ export async function updateClient(
);
}
const { name, siteIds, olmId, secret } = parsedBody.data;
const { name, siteIds } = parsedBody.data;
const parsedParams = updateClientParamsSchema.safeParse(req.params);
if (!parsedParams.success) {
@@ -93,11 +90,6 @@ export async function updateClient(
const { clientId } = parsedParams.data;
let secretHash = undefined;
if (secret) {
secretHash = await hashPassword(secret);
}
// Fetch the client to make sure it exists and the user has access to it
const [client] = await db
@@ -146,22 +138,6 @@ export async function updateClient(
.where(eq(clients.clientId, clientId));
}
const [existingOlm] = await trx
.select()
.from(olms)
.where(eq(olms.clientId, clientId))
.limit(1);
if (existingOlm && olmId && secretHash) {
await trx
.update(olms)
.set({
olmId,
secretHash
})
.where(eq(olms.clientId, clientId));
}
// Update site associations if provided
// Remove sites that are no longer associated
for (const siteId of sitesRemoved) {