Can't call `await getJwtToken(ctx)` on new session?
Trying to generate a JWT after the user signs in via email/pass.
Current code is:
But
getJwtToken
fails with can't user
us undefined, essentially. Is there something I am missing here or is this a bug?5 Replies
Running into the same issue.
Bug is here, needs to check for newSession. https://github.com/better-auth/better-auth/blob/main/packages/better-auth/src/plugins/jwt/index.ts#L178
GitHub
better-auth/packages/better-auth/src/plugins/jwt/index.ts at main ...
The most comprehensive authentication framework for TypeScript - better-auth/better-auth
I'm doing the following hack while we wait for a fix:
Let me open an issue.
GitHub
Error with
getJwtToken
on newSession: TypeError: Cannot read prop...I copied the setup @Bekacru did and ran into the same issue: rocicorp/ztunes#9 (comment) Code: after: createAuthMiddleware(async ctx => { if (ctx.path.indexOf('/callback/') !== -1) { con...
GitHub
Fix
getJwtToken
to look for session
or newSession
. by izakfil...Resolves #3353
Summary by cubic
Updated getJwtToken to use either session or newSession from context, fixing issues when only newSession is present.