| | import apiClient from './apiClient'; |
| |
|
| | |
| | |
| | |
| | |
| | class AuthService { |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | async register(userData) { |
| | try { |
| | |
| | if (import.meta.env.VITE_NODE_ENV === 'development') { |
| | console.log('🔐 [AuthService] Registration data being sent:', { |
| | hasConfirmPassword: 'confirmPassword' in userData, |
| | hasConfirmPassword: 'confirm_password' in userData, |
| | dataKeys: Object.keys(userData), |
| | fullData: userData |
| | }); |
| | } |
| |
|
| | const response = await apiClient.post('/auth/register', userData); |
| | return response; |
| | } catch (error) { |
| | console.error('AuthService: Registration error', error); |
| | |
| | if (!error.response) { |
| | throw new Error('Network error - please check your connection'); |
| | } |
| | throw error; |
| | } |
| | } |
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | async login(credentials) { |
| | try { |
| | const response = await apiClient.post('/auth/login', credentials); |
| | return response; |
| | } catch (error) { |
| | console.error('AuthService: Login error', error); |
| | |
| | if (!error.response) { |
| | throw new Error('Network error - please check your connection'); |
| | } |
| | throw error; |
| | } |
| | } |
| |
|
| | |
| | |
| | |
| | |
| | async logout() { |
| | try { |
| | |
| | |
| | |
| | const response = await apiClient.post('/auth/logout'); |
| | return response; |
| | } catch (error) { |
| | console.warn('AuthService: Logout error (continuing anyway):', error.message); |
| | |
| | |
| | return { data: { success: true, message: 'Logged out successfully' } }; |
| | } |
| | } |
| |
|
| | |
| | |
| | |
| | |
| | async getCurrentUser() { |
| | try { |
| | const response = await apiClient.get('/auth/user'); |
| | return response; |
| | } catch (error) { |
| | console.error('AuthService: Get user error', error); |
| | |
| | if (!error.response) { |
| | throw new Error('Network error - please check your connection'); |
| | } |
| | throw error; |
| | } |
| | } |
| |
|
| | |
| | |
| | |
| | |
| | |
| | async forgotPassword(email) { |
| | try { |
| | const response = await apiClient.post('/auth/forgot-password', { email }); |
| | return response; |
| | } catch (error) { |
| | console.error('AuthService: Forgot password error', error); |
| | |
| | if (!error.response) { |
| | throw new Error('Network error - please check your connection'); |
| | } |
| | throw error; |
| | } |
| | } |
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | async resetPassword(resetData) { |
| | try { |
| | const response = await apiClient.post('/auth/reset-password', resetData); |
| | return response; |
| | } catch (error) { |
| | console.error('AuthService: Reset password error', error); |
| | |
| | if (!error.response) { |
| | throw new Error('Network error - please check your connection'); |
| | } |
| | throw error; |
| | } |
| | } |
| | } |
| |
|
| | |
| | export default new AuthService(); |