fix: 收口依赖兼容与会话撤销
为 miniprogram-ci 和 Jimp 依赖增加兼容 patch 与 smoke test;修复平台模板管理员路由漏配;收紧模板契约校验;为 admin/customer 增加 token 撤销和集中会话存储;同步品牌切换角色、doctor source hash、多屏宽截图证据和 CI 构建门禁。
This commit is contained in:
1 parent
4f0b50c7f1
commit
3017e3eb49
65 files changed
+1623
-975
No files matched your search
@@ -160,6 +160,10 @@ export class ApiClient
|
||||
this.resources.session.loginAdmin(...arguments_);
|
||||
changeAdminPassword = (...arguments_: Parameters<SessionMethods["changeAdminPassword"]>) =>
|
||||
this.resources.session.changeAdminPassword(...arguments_);
|
||||
logoutAdmin = (...arguments_: Parameters<SessionMethods["logoutAdmin"]>) =>
|
||||
this.resources.session.logoutAdmin(...arguments_);
|
||||
logoutCustomer = (...arguments_: Parameters<SessionMethods["logoutCustomer"]>) =>
|
||||
this.resources.session.logoutCustomer(...arguments_);
|
||||
listCustomerBookings = (...arguments_: Parameters<BookingMethods["listCustomerBookings"]>) =>
|
||||
this.resources.booking.listCustomerBookings(...arguments_);
|
||||
createCustomerBooking = (...arguments_: Parameters<BookingMethods["createCustomerBooking"]>) =>
|
||||
|
||||
@@ -15,7 +15,7 @@ export interface BrandMethods {
|
||||
listAdminBrands(): Promise<AdminBrandMembership[]>;
|
||||
switchAdminBrand(
|
||||
brandId: string,
|
||||
): Promise<{ token: string; brand: AdminBrandMembership["brand"] }>;
|
||||
): Promise<{ token: string; role: string; brand: AdminBrandMembership["brand"] }>;
|
||||
listAdminMembers(): Promise<AdminBrandMember[]>;
|
||||
createAdminMember(body: {
|
||||
username: string;
|
||||
|
||||
@@ -12,6 +12,8 @@ export interface SessionMethods {
|
||||
platformTemplateRole: "none" | "template_admin";
|
||||
}>;
|
||||
changeAdminPassword(currentPassword: string, newPassword: string): Promise<{ changed: true }>;
|
||||
logoutAdmin(): Promise<{ loggedOut: true }>;
|
||||
logoutCustomer(): Promise<{ loggedOut: true }>;
|
||||
}
|
||||
|
||||
export function sessionMethods({ request }: { request: RequestFn }): SessionMethods {
|
||||
@@ -23,5 +25,7 @@ export function sessionMethods({ request }: { request: RequestFn }): SessionMeth
|
||||
method: "POST",
|
||||
body: { currentPassword, newPassword },
|
||||
}),
|
||||
logoutAdmin: () => request("/admin/session/logout", { method: "POST", body: {} }),
|
||||
logoutCustomer: () => request("/customer/session/logout", { method: "POST", body: {} }),
|
||||
};
|
||||
}
|
||||
@@ -27,6 +27,24 @@ test("客户端发送认证头、查询参数和 JSON 请求体", async () => {
|
||||
assert.equal(calls[1]?.init?.body, JSON.stringify({ name: "重点" }));
|
||||
});
|
||||
|
||||
test("客户端登出会调用当前会话接口", async () => {
|
||||
const calls: Array<{ url: string; method?: string; body?: string }> = [];
|
||||
const client = new ApiClient({
|
||||
baseUrl: "http://api.test",
|
||||
token: "admin-token",
|
||||
fetcher: async (url, init) => {
|
||||
calls.push({ url, method: init?.method, body: init?.body });
|
||||
return response({ loggedOut: true });
|
||||
},
|
||||
});
|
||||
await client.logoutAdmin();
|
||||
await client.logoutCustomer();
|
||||
assert.deepEqual(calls, [
|
||||
{ url: "http://api.test/admin/session/logout", method: "POST", body: "{}" },
|
||||
{ url: "http://api.test/customer/session/logout", method: "POST", body: "{}" },
|
||||
]);
|
||||
});
|
||||
|
||||
test("客户端将统一错误响应转换为 ApiClientError", async () => {
|
||||
const client = new ApiClient({
|
||||
baseUrl: "http://api.test",
|
||||
|
||||
Reference in new issue
Block a user