Lucia v2 (beta 3): One final push #791
pilcrowonpaper
announced in
Announcements
Replies: 1 comment 7 replies
-
curious, where are type my other code also gave an error when i did const authRequest = auth.handleRequest({
request: request as NextRequest,
cookies,
}) i can't find anything for Type '() => ReadonlyRequestCookies' is not assignable to type '{ get: (name: string) => NextJsCookie; }'.ts(2322)
(property) cookies: () => ReadonlyRequestCookies the code looks like: import { cookies } from 'next/headers'
import { redirect } from 'next/navigation'
import { auth } from '@/app/auth/lucia'
export const validateSession = async (url: string, sessionExists: boolean) => {
const authRequest = auth.handleRequest({ cookies })
const session = await authRequest.validate()
if (sessionExists) {
if (session) redirect(url)
} else {
if (!session) redirect(url)
return session
}
} i modified it a bit for redirects when session exists & when it doesn't exist. |
Beta Was this translation helpful? Give feedback.
7 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
This is a major update to Lucia, and it should be the last one!
Session reset
Instead of a new session being created (renewal), the expiration of the session is extended if it's idle (reset).
Auth.renewSession()
has been removed accordingly.Middleware
With v2, Lucia no longer needs to set new session cookies when validating sessions if
sessionCookie.expires
configuration is disabled.This should only be enabled when necessary:
nextjs()
Auth.handleRequest()
no longer acceptsResponse
andHeaders
when using the Next.js middleware. Passing onlyIncomingMessage
orRequest
will disableAuthRequest.setSession()
. We recommend setting cookies manually when creating a new session.request
must be defined as well:web()
Auth.handleRequest()
no longer acceptsResponse
andHeaders
when using the web standard middleware. This meansAuthRequest.setSession()
is disabled, and we recommend setting cookies manually.Creating sessions and keys
Auth.createSession()
andAuth.createKey()
now takes a single parameter.ProviderUserAuth.createUser()
has been updated accordingly as well.Generate custom user and session id
generateUserId()
configuration has been removed. Instead, you can now just pass the id when creating a user or session.Beta Was this translation helpful? Give feedback.
All reactions