Add PocketBase token context diagnostics

This commit is contained in:
2026-03-29 03:22:51 +00:00
parent a34b362683
commit a045a1fbd8
2 changed files with 59 additions and 6 deletions
+14 -2
View File
@@ -311,7 +311,13 @@
});
const data = await resp.json().catch(() => ({}));
if (!resp.ok || !data?.success) {
throw new Error(data?.message || 'Failed to load users');
const details = data?.details
? (typeof data.details === 'string' ? data.details : JSON.stringify(data.details))
: '';
const context = data?.tokenContext ? ` tokenContext=${JSON.stringify(data.tokenContext)}` : '';
throw new Error(details
? `${data?.message || 'Failed to load users'}: ${details}${context}`
: `${data?.message || 'Failed to load users'}${context}`);
}
usersCache = Array.isArray(data.users) ? data.users : [];
@@ -390,7 +396,10 @@
const details = data?.details
? (typeof data.details === 'string' ? data.details : JSON.stringify(data.details))
: '';
throw new Error(details ? `${data?.message || 'Failed to load tasks'}: ${details}` : (data?.message || 'Failed to load tasks'));
const context = data?.tokenContext ? ` tokenContext=${JSON.stringify(data.tokenContext)}` : '';
throw new Error(details
? `${data?.message || 'Failed to load tasks'}: ${details}${context}`
: `${data?.message || 'Failed to load tasks'}${context}`);
}
if (data?.userName && taskUserSelect.value !== data.userName) {
taskUserSelect.value = data.userName;
@@ -401,6 +410,7 @@
userName: data?.userName || userName,
userId: data?.userId || undefined,
authUser: data?.authUser || undefined,
tokenContext: data?.tokenContext || undefined,
lookupMethod: data?.lookupMethod || undefined,
warning: data?.warning || undefined,
tasks: data.tasks || [],
@@ -416,6 +426,8 @@
try {
await client.collection(config.collection).authRefresh();
} catch {
client.authStore.clear();
writeOutput('Existing PocketBase session could not refresh for Users collection. Please login again.');
}
}