more auth ree
This commit is contained in:
@@ -15,7 +15,7 @@ export const fetchMe = createServerFn()
|
||||
const request = getRequest();
|
||||
|
||||
try {
|
||||
const context = await getSessionContext(request);
|
||||
const context = await getSessionContext(request, { isServerFunction: true });
|
||||
|
||||
await pbAdmin.authPromise;
|
||||
const result = await pbAdmin.getPlayerByAuthId(context.userAuthId);
|
||||
@@ -55,6 +55,24 @@ export const fetchMe = createServerFn()
|
||||
}
|
||||
}
|
||||
|
||||
if (error?.message === "SESSION_REFRESH_REQUIRED") {
|
||||
logger.info("FetchMe: Session refresh required (server function)");
|
||||
throw new Response(
|
||||
JSON.stringify({
|
||||
error: "SESSION_REFRESH_REQUIRED",
|
||||
message: "Session needs to be refreshed",
|
||||
shouldRetry: true
|
||||
}),
|
||||
{
|
||||
status: 440,
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
"X-Session-Expired": "true"
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
if (error?.message === "Unauthenticated") {
|
||||
logger.info("FetchMe: No authenticated user (expected when not logged in)");
|
||||
return { user: undefined, roles: [], metadata: {}, phone: undefined };
|
||||
|
||||
Reference in New Issue
Block a user