Django/DRF + PostgreSQL/Redis/Celery backend with accounts, library, moments, and notifications apps; React/TypeScript/Vite frontend with Instagram-style sidebar nav, feed, profiles, nested comment replies, notifications, and photo/video upload with ffmpeg-generated posters. Co-Authored-By: Claude Sonnet 5 <[email protected]>
26 lines
717 B
TypeScript
26 lines
717 B
TypeScript
import { api, tokenStorage } from './client'
|
|
import type { User } from './types'
|
|
|
|
interface TokenPair {
|
|
access: string
|
|
refresh: string
|
|
}
|
|
|
|
export async function login(email: string, password: string): Promise<void> {
|
|
const tokens = await api.post<TokenPair>('/api/auth/token/', { email, password })
|
|
tokenStorage.set(tokens.access, tokens.refresh)
|
|
}
|
|
|
|
export async function register(email: string, username: string, password: string): Promise<void> {
|
|
await api.post<User>('/api/accounts/register/', { email, username, password })
|
|
await login(email, password)
|
|
}
|
|
|
|
export function logout(): void {
|
|
tokenStorage.clear()
|
|
}
|
|
|
|
export function getMe(): Promise<User> {
|
|
return api.get<User>('/api/accounts/me/')
|
|
}
|