feat: 添加登出和修改密码的API
This commit is contained in:
@@ -49,4 +49,8 @@ export async function loginBySms(phone: string, code: string) {
|
|||||||
code,
|
code,
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function logout() {
|
||||||
|
return clientFetch('/api/auth/logout', { method: 'POST' });
|
||||||
}
|
}
|
||||||
@@ -1,6 +1,20 @@
|
|||||||
import { User } from "@/lib/types/user";
|
import { User } from "@/lib/types/user";
|
||||||
import { clientFetch } from "../client";
|
import { clientFetch } from "../client";
|
||||||
|
import { APIError } from "../common";
|
||||||
|
|
||||||
export async function me() {
|
export async function me() {
|
||||||
return clientFetch<User>('/api/user/me');
|
return clientFetch<User>('/api/user/me');
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function updatePassword(password: string) {
|
||||||
|
if (! /^(?=.*[a-zA-Z])(?=.*\d)[a-zA-Z\d!@#$%^&*()_+\-=\[\]{};:'",.<>/?]{6,32}$/.test(password)) {
|
||||||
|
throw new APIError('新密码不符合规范,请重新输入')
|
||||||
|
}
|
||||||
|
|
||||||
|
return clientFetch<null>('/api/user/password', {
|
||||||
|
method: 'PUT',
|
||||||
|
body: JSON.stringify({
|
||||||
|
password,
|
||||||
|
}),
|
||||||
|
})
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user