File size: 1,554 Bytes
ad74240 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 | 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; |