fix: return database user ID from /api/auth/me instead of Logto sub
Some checks failed
CI / ci (push) Failing after 1m8s
CI / deploy (push) Has been skipped
CI / e2e (push) Has been skipped

The /me endpoint was returning auth.sub (Logto's opaque string) as the
user ID, but the frontend and other API endpoints expect numeric DB IDs.
This caused "can't access property 'id', w[0] is undefined" after login.

Also documents Logto OIDC setup requirements (scopes, env vars) in
CLAUDE.md.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-04-08 22:16:59 +02:00
parent 9dca657ab1
commit 3b29248845
2 changed files with 20 additions and 4 deletions

View File

@@ -8,6 +8,7 @@ import { requireAuth } from "../middleware/auth.ts";
import {
createApiKey,
deleteApiKey,
getOrCreateUser,
listApiKeys,
} from "../services/auth.service.ts";
import { updateProfile } from "../services/profile.service.ts";
@@ -23,8 +24,10 @@ const app = new Hono<Env>();
app.get("/me", async (c) => {
const auth = await getAuth(c);
if (auth) {
const db = c.get("db");
const user = await getOrCreateUser(db, auth.sub);
return c.json({
user: { id: auth.sub, email: auth.email },
user: { id: user.id, email: auth.email },
authenticated: true,
});
}