feat: 更新认证逻辑,支持通过openid查找或创建用户,并调整JWT负载字段
This commit is contained in:
@@ -27,9 +27,9 @@ export function LoginPage() {
|
||||
if (tokenFromUrl !== oldToken) {
|
||||
const payload = decodeToken(tokenFromUrl);
|
||||
setTokenAndUser(tokenFromUrl, {
|
||||
id: payload.sub,
|
||||
id: String(payload.uid),
|
||||
openid: payload.openid,
|
||||
phone: payload.mobile,
|
||||
phone: payload.phone,
|
||||
});
|
||||
} else {
|
||||
// token 没变,确保 localStorage 有数据
|
||||
|
||||
@@ -55,9 +55,9 @@ async function fetchApi<T>(path: string, options: RequestInit = {}): Promise<T>
|
||||
// ─── Auth ───
|
||||
|
||||
export interface TokenPayload {
|
||||
sub: string; // user_id
|
||||
uid: number;
|
||||
openid: string;
|
||||
mobile: string;
|
||||
phone: string;
|
||||
exp: number;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user