Вроде работает

This commit is contained in:
2026-01-30 11:10:16 +03:00
parent 8044f85ea4
commit 252a8601a9
43 changed files with 1987 additions and 270 deletions

View File

@@ -13,6 +13,7 @@
<script lang="ts">
import { onMount } from 'svelte';
import { auth } from '../../lib/auth/store';
import { api } from '../../lib/api';
import { goto } from '$app/navigation';
let username = '';
@@ -53,18 +54,12 @@
auth.setToken(data.access_token);
// Fetch user profile
const profileRes = await fetch('/api/auth/me', {
headers: {
'Authorization': `Bearer ${data.access_token}`
}
});
if (profileRes.ok) {
const user = await profileRes.json();
try {
const user = await api.fetchApi('/auth/me');
auth.setUser(user);
goto('/');
} else {
error = 'Failed to fetch user profile';
} catch (err) {
error = 'Failed to fetch user profile: ' + err.message;
}
} else {
const errData = await response.json();