Skip to content

armgit / kaneo

Public Imported from GitHub
0

⚡ Project management that doesn't become the project. Boards, Gantt charts, and GitHub integration. Self-host it or use Kaneo Cloud.

fix(admin): allow updating your own email without changing role

Tin3d57439d59c7
diff --git a/apps/web/src/components/admin/user-management-panel.tsx b/apps/web/src/components/admin/user-management-panel.tsx
index f7e381445..6d20b09e7 100644
--- a/apps/web/src/components/admin/user-management-panel.tsx
+++ b/apps/web/src/components/admin/user-management-panel.tsx
@@ -167,12 +167,9 @@ function UserManagementPanel() {
userId: editingUser.id,
name,
email,
- role:
- editingUser.id === currentUser?.id
- ? editingUser.role === "admin"
- ? "admin"
- : "user"
- : editValues.role,
+ ...(editingUser.id !== currentUser?.id
+ ? { role: editValues.role }
+ : {}),
});
setEditingUser(null);
} catch {
diff --git a/apps/web/src/fetchers/admin/types.ts b/apps/web/src/fetchers/admin/types.ts
index f8f2a7917..28fd05a85 100644
--- a/apps/web/src/fetchers/admin/types.ts
+++ b/apps/web/src/fetchers/admin/types.ts
@@ -23,7 +23,7 @@ export type UpdateAdminUserRequest = {
userId: string;
name: string;
email: string;
- role: "admin" | "user";
+ role?: "admin" | "user";
};
export type ToggleAdminUserStatusRequest = {
diff --git a/apps/web/src/fetchers/admin/update-admin-user.ts b/apps/web/src/fetchers/admin/update-admin-user.ts
index 8cac24a90..340aa8296 100644
--- a/apps/web/src/fetchers/admin/update-admin-user.ts
+++ b/apps/web/src/fetchers/admin/update-admin-user.ts
@@ -9,7 +9,7 @@ export async function updateAdminUser({
}: UpdateAdminUserRequest) {
const { data, error } = await authClient.admin.updateUser({
userId,
- data: { name, email, role },
+ data: { name, email, ...(role === undefined ? {} : { role }) },
});
if (error) {