Fix token UI to use SDK rest client (sw.api.get/post/del)
All checks were successful
CI/CD / detect-changes (pull_request) Successful in 4s
CI/CD / test-runners (pull_request) Has been skipped
CI/CD / e2e-smoke (pull_request) Has been skipped
CI/CD / test-frontend (pull_request) Successful in 6s
CI/CD / test-go-pg (pull_request) Successful in 2m42s
CI/CD / test-sqlite (pull_request) Successful in 3m5s
CI/CD / build-and-deploy (pull_request) Successful in 1m10s
All checks were successful
CI/CD / detect-changes (pull_request) Successful in 4s
CI/CD / test-runners (pull_request) Has been skipped
CI/CD / e2e-smoke (pull_request) Has been skipped
CI/CD / test-frontend (pull_request) Successful in 6s
CI/CD / test-go-pg (pull_request) Successful in 2m42s
CI/CD / test-sqlite (pull_request) Successful in 3m5s
CI/CD / build-and-deploy (pull_request) Successful in 1m10s
The frontend SDK doesn't expose sw.api.fetch — use sw.api.get(), sw.api.post(), sw.api.del() with full /api/v1/ paths instead. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -91,7 +91,7 @@ export default function UsersSection() {
|
||||
const name = await sw.prompt(`Token name for "${username}":`, '');
|
||||
if (!name) return;
|
||||
try {
|
||||
const resp = await sw.api.fetch('POST', '/admin/tokens', {
|
||||
const resp = await sw.api.post('/api/v1/admin/tokens', {
|
||||
user_id: userId, name, permissions: [],
|
||||
});
|
||||
await sw.alert(`Token created for ${username}. Copy it now — it won't be shown again:\n\n${resp.token}`);
|
||||
|
||||
@@ -20,8 +20,8 @@ export function TokensSection() {
|
||||
|
||||
const load = useCallback(async () => {
|
||||
try {
|
||||
const resp = await sw.api.fetch('GET', '/auth/tokens');
|
||||
setTokens(resp?.data || []);
|
||||
const resp = await sw.api.get('/api/v1/auth/tokens');
|
||||
setTokens(resp || []);
|
||||
} catch (e) {
|
||||
setTokens([]);
|
||||
}
|
||||
@@ -29,7 +29,7 @@ export function TokensSection() {
|
||||
|
||||
const loadPerms = useCallback(async () => {
|
||||
try {
|
||||
const resp = await sw.api.fetch('GET', '/profile/permissions');
|
||||
const resp = await sw.api.get('/api/v1/profile/permissions');
|
||||
setAvailablePerms(resp?.permissions || []);
|
||||
} catch (_) {}
|
||||
}, []);
|
||||
@@ -65,7 +65,7 @@ export function TokensSection() {
|
||||
try {
|
||||
const body = { name: form.name, permissions: form.permissions };
|
||||
if (form.expires_at) body.expires_at = new Date(form.expires_at).toISOString();
|
||||
const resp = await sw.api.fetch('POST', '/auth/tokens', body);
|
||||
const resp = await sw.api.post('/api/v1/auth/tokens', body);
|
||||
setCreatedToken(resp.token);
|
||||
setShowForm(false);
|
||||
load();
|
||||
@@ -80,7 +80,7 @@ export function TokensSection() {
|
||||
const revoke = useCallback(async (id, name) => {
|
||||
if (!await sw.confirm(`Revoke token "${esc(name)}"? This action cannot be undone.`)) return;
|
||||
try {
|
||||
await sw.api.fetch('DELETE', `/auth/tokens/${id}`);
|
||||
await sw.api.del(`/api/v1/auth/tokens/${id}`);
|
||||
sw.emit('toast', { message: 'Token revoked', variant: 'success' });
|
||||
load();
|
||||
} catch (e) {
|
||||
|
||||
Reference in New Issue
Block a user