;s;
This commit is contained in:
@@ -79,19 +79,26 @@ export async function pbLogout(): Promise<void> {
|
||||
}
|
||||
}
|
||||
|
||||
/** 获取当前存储的用户邮箱 */
|
||||
export function getStoredUserEmail(): string | null {
|
||||
/** 获取当前存储的用户(id + email) */
|
||||
export function getStoredUser(): AuthUser | null {
|
||||
if (typeof window === "undefined") return null;
|
||||
try {
|
||||
const raw = localStorage.getItem(PB_STORAGE_KEYS.user);
|
||||
if (!raw) return null;
|
||||
const user = JSON.parse(raw);
|
||||
return user?.email ?? null;
|
||||
if (!user?.id || !user?.email) return null;
|
||||
return { id: user.id, email: user.email };
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/** 获取当前存储的用户邮箱 */
|
||||
export function getStoredUserEmail(): string | null {
|
||||
const user = getStoredUser();
|
||||
return user?.email ?? null;
|
||||
}
|
||||
|
||||
/** 获取存储的 token(用于 API 请求) */
|
||||
export function getStoredToken(): string | null {
|
||||
if (typeof window === "undefined") return null;
|
||||
|
||||
@@ -3,6 +3,7 @@ export {
|
||||
pbRegister,
|
||||
pbSaveAuth,
|
||||
pbLogout,
|
||||
getStoredUser,
|
||||
getStoredUserEmail,
|
||||
getStoredToken,
|
||||
} from "./auth";
|
||||
|
||||
Reference in New Issue
Block a user