用户认证
CSRF Cookie
GET /csrf-cookie
登录
POST /login
async handleLogin() {
await axios.get(`/csrf-cookie`);
await axios.post(`/login`, {
email: "test@example.com",
password: "password",
remember: true
}).then(response => {
console.log(response);
if (response.data.two_factor) {
/**
* Two Factor Authentication...
*/
} else {
router.push({ path: '/dashboard' });
}
}).catch(error => {
console.log(error);
});
}
登出
POST /logout
axios.post(`/logout`).then(() => {
router.push({ path: '/login' });
}).catch(error => {
console.log(error);
});
注册
POST /register
axios.post(`/register`, {
email: "test@example.com",
password: "password",
password_confirmation: "password",
name: "张三",
}).then(() => {
// 成功...
}).catch(error => {
console.error(error);
});
忘记密码
POST /forgot-password
axios.post(`/forgot-password`, {
email: "test@example.com"
}).then(() => {
// 成功...
}).catch(error => {
console.error(error);
});
重置密码
POST /reset-password
axios.post(`/reset-password`, {
password: "password",
password_confirmation: "password",
}).then(() => {
// 成功...
}).catch(error => {
console.error(error);
});
获取用户信息
GET /user
axios.get(`/user`).then(response => {
console.log(response);
}).catch(error => {
console.error(error);
});
修改个人资料
PUT /user/profile-information
axios.put(`/user/profile-information`, {
email: "test@example.com",
name: "张三",
}).then(() => {
// 成功...
}).catch(error => {
console.error(error);
});
修改密码
PUT /user/password
axios.put(`/user/password`, {
current_password: "password",
password: "password",
password_confirmation: "password",
}).then(() => {
// 成功...
}).catch(error => {
console.error(error);
});
