Maia/frontend/src/api/auth.ts

22 lines
786 B
TypeScript

import api from './axios'
import type { User } from '@/types'
export const authApi = {
login: (email: string, password: string) =>
api.post<{ access_token: string; refresh_token: string; user: User }>('/auth/login', { email, password }),
register: (name: string, email: string, password: string) =>
api.post<{ access_token: string; refresh_token: string; user: User }>('/auth/register', { name, email, password }),
refresh: (refresh_token: string) =>
api.post<{ access_token: string }>('/auth/refresh', { refresh_token }),
keycloakAuth: async (kcToken: string) => {
const response = await api.post<{ access_token: string; refresh_token: string; token_type: string }>(
'/auth/keycloak',
{ kc_token: kcToken }
)
return response.data
},
}