feat: add frontend auth shell
This commit is contained in:
20
frontend/src/features/auth/api.ts
Normal file
20
frontend/src/features/auth/api.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
import { apiRequest } from '@/lib/api'
|
||||
|
||||
import type { CurrentUser } from './types'
|
||||
|
||||
export async function getCurrentUser() {
|
||||
return apiRequest<CurrentUser>('/accounts/auth/me')
|
||||
}
|
||||
|
||||
export async function login(username: string, password: string) {
|
||||
return apiRequest<CurrentUser>('/accounts/auth/login', {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({ username, password })
|
||||
})
|
||||
}
|
||||
|
||||
export async function logout() {
|
||||
await apiRequest<{ status: string }>('/accounts/auth/logout', {
|
||||
method: 'POST'
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user