feat: похуйу

This commit is contained in:
2026-05-12 21:50:41 +03:00
parent 36c63a2597
commit e310eafa1e
3 changed files with 25 additions and 5 deletions

View File

@@ -0,0 +1,21 @@
import { getCsrfToken } from '@shared/api/csrf'
import { tokenStore } from '@shared/api/tokenStore'
const USERS_API_URL = 'https://app.users.elcsa.ru'
export async function getMe(): Promise<unknown> {
const csrf = await getCsrfToken()
const bearer = tokenStore.get()
const res = await fetch(`${USERS_API_URL}/me`, {
credentials: 'include',
headers: {
'X-CSRF-Token': csrf,
...(bearer ? { Authorization: `Bearer ${bearer}` } : {}),
},
})
const data = await res.json()
if (!res.ok) throw data
return data
}

View File

@@ -1,4 +1,5 @@
export { registrationStart, registrationComplete, loginStart, loginComplete } from './api/registrationApi' export { registrationStart, registrationComplete, loginStart, loginComplete } from './api/registrationApi'
export { getMe } from './api/profileApi'
export type { RegistrationStartPayload, RegistrationCompletePayload, LoginStartPayload, LoginCompletePayload, AuthResponse } from './api/registrationApi' export type { RegistrationStartPayload, RegistrationCompletePayload, LoginStartPayload, LoginCompletePayload, AuthResponse } from './api/registrationApi'
export { useIsAuthenticated } from './hooks/useIsAuthenticated' export { useIsAuthenticated } from './hooks/useIsAuthenticated'
export { useAuth, AUTH_QUERY_KEY } from './hooks/useAuth' export { useAuth, AUTH_QUERY_KEY } from './hooks/useAuth'

View File

@@ -1,4 +1,5 @@
import { useEffect } from 'react' import { useEffect } from 'react'
import { getMe } from '@features/auth'
import { Button, FormField } from '@shared/ui' import { Button, FormField } from '@shared/ui'
import { WalletHeader } from '@widgets/wallet-header' import { WalletHeader } from '@widgets/wallet-header'
import { ProfileAvatar, ProfileSection } from '@widgets/profile' import { ProfileAvatar, ProfileSection } from '@widgets/profile'
@@ -6,11 +7,8 @@ import styles from './ProfilePage.module.css'
export function ProfilePage() { export function ProfilePage() {
useEffect(() => { useEffect(() => {
fetch('https://app.users.elcsa.ru/me', { credentials: 'include' }) getMe()
.then(async (res) => { .then((data) => console.log('[/me]', data))
const data = await res.json().catch(() => null)
console.log('[/me] status:', res.status, 'body:', data)
})
.catch((err) => console.error('[/me] error:', err)) .catch((err) => console.error('[/me] error:', err))
}, []) }, [])