| import api from './api';
|
|
|
| const authService = {
|
|
|
| loginWithPassword: async (username, password) => {
|
| return api.post('/auth/login-password', { username, password });
|
| },
|
|
|
|
|
| loginWithEmailCode: async (email, emailCode, role = 'student') => {
|
| return api.post('/auth/login-email', { email, code: emailCode, role });
|
| },
|
|
|
|
|
| loginWithPhoneCode: async (phone, phoneCode, role = 'student') => {
|
| return api.post('/auth/login-phone', { phone, code: phoneCode, role });
|
| },
|
|
|
|
|
| sendEmailCode: async (email) => {
|
| return api.post('/auth/send-email-code', { email });
|
| },
|
|
|
|
|
| sendPhoneCode: async (phone) => {
|
| return api.post('/auth/send-phone-code', { phone });
|
| },
|
|
|
|
|
| register: async (data) => {
|
| return api.post('/auth/register', data);
|
| },
|
|
|
|
|
| logout: async () => {
|
| return api.post('/auth/logout');
|
| },
|
|
|
|
|
| refreshToken: async () => {
|
| return api.post('/auth/refresh');
|
| },
|
|
|
|
|
| getCurrentUser: async () => {
|
| return api.get('/auth/me');
|
| },
|
|
|
|
|
| changePassword: async (oldPassword, newPassword) => {
|
| return api.post('/auth/change_password', { oldPassword, newPassword });
|
| },
|
|
|
|
|
| resetPassword: async (token, newPassword) => {
|
| return api.post('/auth/reset_password', { token, newPassword });
|
| },
|
| };
|
|
|
| export default authService; |