agent / frontend /src /services /authService.js
samlax12's picture
Upload 139 files
ad74240 verified
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');
},
// 刷新token
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;