Files
aurora-moments/web/src/api/auth.ts
T
KrisandClaude Sonnet 5 4877e0a779 Initial commit: Aurora Moments self-hosted photo/video sharing platform
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]>
2026-08-10 10:28:53 -05:00

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/')
}