Skip to content

Commit

Permalink
fix constants for v2
Browse files Browse the repository at this point in the history
  • Loading branch information
pilcrowonpaper committed Nov 30, 2023
1 parent 8f278d6 commit a6a8e7e
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions documentation-v3/src/pages/upgrade-v3/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ Here's the base config. Lucia is now initialized using the `Lucia` class, which
import { Lucia, TimeSpan } from "lucia";
import { astro } from "lucia/middleware";

export const lucia = new Lucia(adapter, {
export const auth = new Lucia(adapter, {
sessionCookie: {
attributes: {
secure: env === "PRODUCTION" // replaces `env` config
Expand All @@ -53,7 +53,7 @@ Here's the full updated configuration.
import { Lucia, TimeSpan } from "lucia";
import { astro } from "lucia/middleware";

export const lucia = new Lucia(adapter, {
export const auth = new Lucia(adapter, {
getSessionAttributes: (attributes) => {
return {
ipCountry: attributes.ip_country
Expand Down Expand Up @@ -88,7 +88,7 @@ export const lucia = new Lucia(adapter, {
Lucia v3 uses the newer module syntax instead of `.d.ts` files for declaring types for improved agronomics and monorepo support. The `Lucia` type declaration is required.

```ts
export const lucia = new Lucia();
export const auth = new Lucia();

declare module "lucia" {
interface Register {
Expand Down Expand Up @@ -143,7 +143,7 @@ const sessionId = session.id;

```ts
// v3
const { session, user } = await lucia.validateSession(sessionId);
const { session, user } = await auth.validateSession(sessionId);
if (!session) {
// invalid session
}
Expand All @@ -161,8 +161,8 @@ const { session, user } = await authRequest.validate(sessionId);
`createSessionCookie()` now takes a session ID instead of a session object, and `createBlankSessionCookie()` should be used for creating blank session cookies.

```ts
const sessionCookie = lucia.createSessionCookie(session.id);
const blankSessionCookie = lucia.createBlankSessionCookie(session.id);
const sessionCookie = auth.createSessionCookie(session.id);
const blankSessionCookie = auth.createBlankSessionCookie(session.id);
```

`AuthRequest.setSession()` has been replaced by `AuthRequest.setSessionCookie()` (which takes a session ID), and you must use `AuthRequest.deleteSessionCookie()` to a delete session cookie.
Expand Down

0 comments on commit a6a8e7e

Please sign in to comment.