more auth ree
Some checks failed
CI/CD Pipeline / Build and Push PocketBase Docker Image (push) Has been cancelled
CI/CD Pipeline / Build and Push App Docker Image (push) Has been cancelled
CI/CD Pipeline / Deploy to Kubernetes (push) Has been cancelled

This commit is contained in:
yohlo
2026-03-02 22:17:05 -06:00
parent 152235dd14
commit 76306cc937
5 changed files with 50 additions and 7 deletions

View File

@@ -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 };