feat: add api key delete (#2210)
Co-authored-by: Meier Lukas <meierschlumpf@gmail.com>
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
import { z } from "zod";
|
||||
|
||||
import { createSaltAsync, hashPasswordAsync } from "@homarr/auth";
|
||||
import { generateSecureRandomToken } from "@homarr/common/server";
|
||||
import { createId, db } from "@homarr/db";
|
||||
import { createId, db, eq } from "@homarr/db";
|
||||
import { apiKeys } from "@homarr/db/schema";
|
||||
|
||||
import { createTRPCRouter, permissionRequiredProcedure } from "../trpc";
|
||||
@@ -39,4 +41,10 @@ export const apiKeysRouter = createTRPCRouter({
|
||||
apiKey: `${id}.${randomToken}`,
|
||||
};
|
||||
}),
|
||||
delete: permissionRequiredProcedure
|
||||
.requiresPermission("admin")
|
||||
.input(z.object({ apiKeyId: z.string() }))
|
||||
.mutation(async ({ ctx, input }) => {
|
||||
await ctx.db.delete(apiKeys).where(eq(apiKeys.id, input.apiKeyId)).limit(1);
|
||||
}),
|
||||
});
|
||||
|
||||
@@ -2584,10 +2584,17 @@
|
||||
"button": {
|
||||
"createApiToken": "Create API token"
|
||||
},
|
||||
"modal": {
|
||||
"delete": {
|
||||
"title": "Delete API token",
|
||||
"text": "This will permanently delete the API token. API clients using this token can no longer authenticate and perform API requests. This action cannot be undone."
|
||||
}
|
||||
},
|
||||
"table": {
|
||||
"header": {
|
||||
"id": "ID",
|
||||
"createdBy": "Created by"
|
||||
"createdBy": "Created by",
|
||||
"actions": "Actions"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user