Вроде работает
This commit is contained in:
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user