فهرست منبع

fix: respect isEnabled state when creating new keys in edit dialog

Previously, when creating a new key through the edit user dialog with
isEnabled set to false, the key would still be created as enabled. This
was because:

1. addKey() function signature was missing the isEnabled parameter
2. The implementation hardcoded is_enabled to true
3. The frontend was passing the value but it was silently ignored

Changes:
- Add isEnabled parameter to addKey() function signature
- Use data.isEnabled ?? true in createKey() call (defaults to true)
- Pass isEnabled: key.isEnabled from unified-edit-dialog

Fixes the issue where disabled keys were always created as enabled.
NightYu 1 ماه پیش
والد
کامیت
3de363a784
2فایلهای تغییر یافته به همراه3 افزوده شده و 1 حذف شده
  1. 2 1
      src/actions/keys.ts
  2. 1 0
      src/app/[locale]/dashboard/_components/user/unified-edit-dialog.tsx

+ 2 - 1
src/actions/keys.ts

@@ -85,6 +85,7 @@ export async function addKey(data: {
   userId: number;
   name: string;
   expiresAt?: string;
+  isEnabled?: boolean;
   canLoginWebUi?: boolean;
   limit5hUsd?: number | null;
   limitDailyUsd?: number | null;
@@ -245,7 +246,7 @@ export async function addKey(data: {
       user_id: data.userId,
       name: validatedData.name,
       key: generatedKey,
-      is_enabled: true,
+      is_enabled: data.isEnabled ?? true,
       expires_at: expiresAt,
       can_login_web_ui: validatedData.canLoginWebUi,
       limit_5h_usd: validatedData.limit5hUsd,

+ 1 - 0
src/app/[locale]/dashboard/_components/user/unified-edit-dialog.tsx

@@ -438,6 +438,7 @@ function UnifiedEditDialogInner({
                   userId: user.id,
                   name: key.name,
                   expiresAt: key.expiresAt || undefined,
+                  isEnabled: key.isEnabled,
                   canLoginWebUi: key.canLoginWebUi,
                   providerGroup: normalizeProviderGroup(key.providerGroup),
                   cacheTtlPreference: key.cacheTtlPreference,