import { User, LoginRequest, RegisterRequest } from '../../../shared/types' import { apiService } from './api' interface AuthResponse { user: User token: string } class AuthService { async login(credentials: LoginRequest): Promise { return await apiService.post('/api/auth/login', credentials) } async register(userData: RegisterRequest): Promise { return await apiService.post('/api/auth/register', userData) } async logout(): Promise { try { await apiService.post('/api/auth/logout') } catch (error) { // Ignore logout errors, clear local storage anyway console.warn('Logout request failed:', error) } } async getCurrentUser(): Promise { return await apiService.get('/api/auth/me') } async refreshToken(): Promise { return await apiService.post('/api/auth/refresh') } async changePassword(data: { currentPassword: string newPassword: string }): Promise { await apiService.post('/api/auth/change-password', data) } async requestPasswordReset(email: string): Promise { await apiService.post('/api/auth/forgot-password', { email }) } async resetPassword(data: { token: string newPassword: string }): Promise { await apiService.post('/api/auth/reset-password', data) } async verifyEmail(token: string): Promise { await apiService.post('/api/auth/verify-email', { token }) } async resendVerificationEmail(): Promise { await apiService.post('/api/auth/resend-verification') } } export const authService = new AuthService()