-
-
Notifications
You must be signed in to change notification settings - Fork 164
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(#854): Add getServerSession
and getToken
to the local provider
#855
base: main
Are you sure you want to change the base?
Conversation
getServerSession
and getToken
to the local-providergetServerSession
and getToken
to the local and refresh-provider
getServerSession
and getToken
to the local and refresh-providergetServerSession
and getToken
to the local provider
commit: |
const providerSpecificTypes: string[] = [] | ||
|
||
if (provider.type === 'authjs') { | ||
providerSpecificTypes.push(` const { getServerSession, getToken, NuxtAuthHandler }: typeof import('${resolve('./runtime/server/services/authjs')}')`) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Question - does this resolve relative to current path or from root? From the docs, it looks like the resolution will happen from the current path which is not correct:
https://nuxt.com/docs/api/advanced/import-meta#builder-properties
if (!token) { | ||
return null | ||
} | ||
return token |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
formatToken
already returns string | null
if (!token) { | |
return null | |
} | |
return token | |
return token |
import { formatToken } from '../../../utils/local' | ||
import { useRuntimeConfig } from '#imports' | ||
|
||
export function getToken(event: H3Event) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
export function getToken(event: H3Event) { | |
export function getToken(event: H3Event): string | null { |
import type { SessionData } from '#auth' | ||
import { useRuntimeConfig } from '#imports' | ||
|
||
function joinPathToApiURL(event: H3Event, path: string) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: would prefer if this was down the file as it is a helper (consumers are more interested in reading getServerSession
baseURL = fullBaseUrl | ||
} | ||
else { | ||
// Case 2: An origin was not supplied, we determine it from the request |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This probably needs to happen only when trustHost
is set (look at authjs
implementation)
π Linked issue
Closes #854
β Type of change
π Description
Adds
getServerSession
andgetToken
to the server-side ultis for thelocal
provider.π Checklist