refactor: 收口 Admin 会话与授权边界

This commit is contained in:
que01 committed 2026-10-19 10:13:13 +08:00
1 parent 0788480ce3
commit 4ef4be2071
67 files changed
+1890 -392

No files matched your search

+1 -1
View File
@@ -15,7 +15,7 @@ export interface BrandMethods {
listAdminBrands(): Promise<AdminBrandMembership[]>;
switchAdminBrand(
brandId: string,
): Promise<{ token: string; role: string; brand: AdminBrandMembership["brand"] }>;
): Promise<{ role: string; brand: AdminBrandMembership["brand"] }>;
listAdminMembers(): Promise<AdminBrandMember[]>;
createAdminMember(body: {
username: string;
+13 -10
View File
@@ -1,16 +1,18 @@
import type { RequestFn } from "../client/request.js";
export type AdminSession = {
authenticated: true;
displayName: string;
mustChangePassword: boolean;
role: string;
platformTemplateRole: "none" | "template_admin";
};
export type AdminLoginSession = Omit<AdminSession, "authenticated">;
export interface SessionMethods {
loginAdmin(
username: string,
password: string,
): Promise<{
token: string;
displayName: string;
mustChangePassword: boolean;
role: string;
platformTemplateRole: "none" | "template_admin";
}>;
getAdminSession(): Promise<AdminSession>;
loginAdmin(username: string, password: string): Promise<AdminLoginSession>;
changeAdminPassword(currentPassword: string, newPassword: string): Promise<{ changed: true }>;
logoutAdmin(): Promise<{ loggedOut: true }>;
logoutCustomer(): Promise<{ loggedOut: true }>;
@@ -18,6 +20,7 @@ export interface SessionMethods {
export function sessionMethods({ request }: { request: RequestFn }): SessionMethods {
return {
getAdminSession: () => request("/admin/session/current"),
loginAdmin: (username, password) =>
request("/admin/session/login", { method: "POST", body: { username, password } }),
changeAdminPassword: (currentPassword, newPassword) =>