♻️ refactor(auth): Refactor user authorization handling and improve error logging
This commit is contained in:
parent
cd59d44435
commit
68bc18f584
@ -75,6 +75,8 @@ export default async function RootLayout({
|
|||||||
}: Readonly<{
|
}: Readonly<{
|
||||||
children: React.ReactNode;
|
children: React.ReactNode;
|
||||||
}>) {
|
}>) {
|
||||||
|
const Authorization = (await cookies()).get('Authorization')?.value;
|
||||||
|
|
||||||
const locale = await getLocale();
|
const locale = await getLocale();
|
||||||
const messages = await getMessages();
|
const messages = await getMessages();
|
||||||
|
|
||||||
@ -86,13 +88,15 @@ export default async function RootLayout({
|
|||||||
console.log('Error fetching global config:', error);
|
console.log('Error fetching global config:', error);
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
if (Authorization) {
|
||||||
user = await currentUser({
|
try {
|
||||||
skipErrorHandler: true,
|
user = await currentUser({
|
||||||
Authorization: (await cookies()).get('Authorization')?.value,
|
skipErrorHandler: true,
|
||||||
}).then((res) => res.data.data);
|
Authorization,
|
||||||
} catch (error) {
|
}).then((res) => res.data.data);
|
||||||
console.log('Error fetching current user:', error);
|
} catch (error) {
|
||||||
|
console.log('Error fetching current user:', error);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@ -22,6 +22,7 @@ export default function Providers({
|
|||||||
defaultOptions: {
|
defaultOptions: {
|
||||||
queries: {
|
queries: {
|
||||||
staleTime: 5 * 1000,
|
staleTime: 5 * 1000,
|
||||||
|
retry: false,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
|
|||||||
5
apps/admin/services/admin/typings.d.ts
vendored
5
apps/admin/services/admin/typings.d.ts
vendored
@ -613,11 +613,6 @@ declare namespace API {
|
|||||||
ip_register_limit_duration: number;
|
ip_register_limit_duration: number;
|
||||||
};
|
};
|
||||||
|
|
||||||
type RelayConfig = {
|
|
||||||
dispatch_mode: string;
|
|
||||||
relay_nodes: NodeRelay[];
|
|
||||||
};
|
|
||||||
|
|
||||||
type Response = {
|
type Response = {
|
||||||
/** 状态码 */
|
/** 状态码 */
|
||||||
code?: number;
|
code?: number;
|
||||||
|
|||||||
5
apps/admin/services/common/typings.d.ts
vendored
5
apps/admin/services/common/typings.d.ts
vendored
@ -222,11 +222,6 @@ declare namespace API {
|
|||||||
ip_register_limit_duration: number;
|
ip_register_limit_duration: number;
|
||||||
};
|
};
|
||||||
|
|
||||||
type RelayConfig = {
|
|
||||||
dispatch_mode: string;
|
|
||||||
relay_nodes: NodeRelay[];
|
|
||||||
};
|
|
||||||
|
|
||||||
type ResetPasswordRequest = {
|
type ResetPasswordRequest = {
|
||||||
email: string;
|
email: string;
|
||||||
password: string;
|
password: string;
|
||||||
|
|||||||
@ -69,7 +69,13 @@ export const viewport: Viewport = {
|
|||||||
],
|
],
|
||||||
};
|
};
|
||||||
|
|
||||||
export default async function RootLayout({ children }: { children: React.ReactNode }) {
|
export default async function RootLayout({
|
||||||
|
children,
|
||||||
|
}: Readonly<{
|
||||||
|
children: React.ReactNode;
|
||||||
|
}>) {
|
||||||
|
const Authorization = (await cookies()).get('Authorization')?.value;
|
||||||
|
|
||||||
const locale = await getLocale();
|
const locale = await getLocale();
|
||||||
const messages = await getMessages();
|
const messages = await getMessages();
|
||||||
|
|
||||||
@ -81,13 +87,15 @@ export default async function RootLayout({ children }: { children: React.ReactNo
|
|||||||
console.log('Error fetching global config:', error);
|
console.log('Error fetching global config:', error);
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
if (Authorization) {
|
||||||
user = await queryUserInfo({
|
try {
|
||||||
skipErrorHandler: true,
|
user = await queryUserInfo({
|
||||||
Authorization: (await cookies()).get('Authorization')?.value,
|
skipErrorHandler: true,
|
||||||
}).then((res) => res.data.data);
|
Authorization,
|
||||||
} catch (error) {
|
}).then((res) => res.data.data);
|
||||||
console.log('Error fetching user info:', error);
|
} catch (error) {
|
||||||
|
console.log('Error fetching user info:', error);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@ -22,6 +22,7 @@ export default function Providers({
|
|||||||
defaultOptions: {
|
defaultOptions: {
|
||||||
queries: {
|
queries: {
|
||||||
staleTime: 5 * 1000,
|
staleTime: 5 * 1000,
|
||||||
|
retry: false,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
|
|||||||
5
apps/user/services/common/typings.d.ts
vendored
5
apps/user/services/common/typings.d.ts
vendored
@ -222,11 +222,6 @@ declare namespace API {
|
|||||||
ip_register_limit_duration: number;
|
ip_register_limit_duration: number;
|
||||||
};
|
};
|
||||||
|
|
||||||
type RelayConfig = {
|
|
||||||
dispatch_mode: string;
|
|
||||||
relay_nodes: NodeRelay[];
|
|
||||||
};
|
|
||||||
|
|
||||||
type ResetPasswordRequest = {
|
type ResetPasswordRequest = {
|
||||||
email: string;
|
email: string;
|
||||||
password: string;
|
password: string;
|
||||||
|
|||||||
5
apps/user/services/user/typings.d.ts
vendored
5
apps/user/services/user/typings.d.ts
vendored
@ -358,11 +358,6 @@ declare namespace API {
|
|||||||
ip_register_limit_duration: number;
|
ip_register_limit_duration: number;
|
||||||
};
|
};
|
||||||
|
|
||||||
type RelayConfig = {
|
|
||||||
dispatch_mode: string;
|
|
||||||
relay_nodes: NodeRelay[];
|
|
||||||
};
|
|
||||||
|
|
||||||
type RenewalOrderRequest = {
|
type RenewalOrderRequest = {
|
||||||
subscribe_id: number;
|
subscribe_id: number;
|
||||||
quantity: number;
|
quantity: number;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user