@makolabs/ripple 1.6.3 → 1.6.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -285,6 +285,7 @@ async function fetchUserPermissions(userId) {
|
|
|
285
285
|
return [];
|
|
286
286
|
}
|
|
287
287
|
catch (error) {
|
|
288
|
+
console.error('[fetchUserPermissions] Error fetching user permissions:', error);
|
|
288
289
|
try {
|
|
289
290
|
const allKeysData = await makeAdminRequest('/admin/keys');
|
|
290
291
|
const userKey = allKeysData.data.data.find((key) => key.sub === userId && key.client_id === CLIENT_ID && key.status === 'active');
|
|
@@ -352,16 +353,16 @@ export const updateUserPermissions = command('unchecked', async (options) => {
|
|
|
352
353
|
const allKeysData = await makeAdminRequest(`/admin/keys?client_id=${CLIENT_ID}&sub=${userId}`);
|
|
353
354
|
// Find ALL active keys for this user (not just one)
|
|
354
355
|
const userKeys = (allKeysData?.data?.data || []).filter((key) => key.status === 'active');
|
|
355
|
-
//
|
|
356
|
-
|
|
356
|
+
// Create new key first, then delete old ones (safer order)
|
|
357
|
+
const newKey = await createUserPermissions(userId, permissions);
|
|
358
|
+
// Only delete old keys after new key is successfully created
|
|
359
|
+
if (userKeys.length > 0 && newKey) {
|
|
357
360
|
await Promise.all(userKeys.map((key) => makeAdminRequest(`/admin/keys/${key.id}`, {
|
|
358
361
|
method: 'DELETE'
|
|
359
362
|
}).catch((err) => {
|
|
360
363
|
console.warn(`[updateUserPermissions] Failed to delete key ${key.id}:`, err);
|
|
361
364
|
})));
|
|
362
365
|
}
|
|
363
|
-
// Create one new key with updated permissions
|
|
364
|
-
await createUserPermissions(userId, permissions);
|
|
365
366
|
await refreshTokenIfSelfUpdate(userId);
|
|
366
367
|
}
|
|
367
368
|
catch (error) {
|
|
@@ -164,7 +164,7 @@
|
|
|
164
164
|
role: formData.role,
|
|
165
165
|
permissions: formData.permissions
|
|
166
166
|
};
|
|
167
|
-
|
|
167
|
+
|
|
168
168
|
await onSave(userData, mode);
|
|
169
169
|
handleClose();
|
|
170
170
|
} catch (error) {
|
|
@@ -177,7 +177,7 @@
|
|
|
177
177
|
|
|
178
178
|
function handleRoleChange(roleValue: string) {
|
|
179
179
|
const role = roles?.find((r: Role) => r.value === roleValue);
|
|
180
|
-
|
|
180
|
+
|
|
181
181
|
// Reassign entire formData object to ensure Svelte 5 reactivity
|
|
182
182
|
formData = {
|
|
183
183
|
...formData,
|