Adds full session functionality into Payload's existing local authentication strategy. It's enabled by default, because this is a more secure pattern that we should enforce. However, we have provided an opt-out pattern for those that want to stick to stateless JWT authentication by passing `collectionConfig.auth.useSessions: false`. Todo: - [x] @jessrynkar to update the Next.js server functions for refresh and logout to support these new features - [x] @jessrynkar resolve build errors --------- Co-authored-by: Elliot DeNolf <denolfe@gmail.com> Co-authored-by: Jessica Chowdhury <jessica@trbl.design> Co-authored-by: Jarrod Flesch <30633324+JarrodMFlesch@users.noreply.github.com> Co-authored-by: Sasha <64744993+r1tsuu@users.noreply.github.com>
16 lines
321 B
TypeScript
16 lines
321 B
TypeScript
'use server'
|
|
|
|
import { refresh } from '@payloadcms/next/auth'
|
|
|
|
import config from '../config.js'
|
|
|
|
export async function refreshFunction() {
|
|
try {
|
|
return await refresh({
|
|
config,
|
|
})
|
|
} catch (error) {
|
|
throw new Error(`Refresh failed: ${error instanceof Error ? error.message : 'Unknown error'}`)
|
|
}
|
|
}
|