Skip to content

Commit

Permalink
correct the code snippet in doc (#1584)
Browse files Browse the repository at this point in the history
  • Loading branch information
mpal15 committed May 30, 2024
1 parent 019b27e commit 6fd5f7e
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions docs/pages/tutorials/username-and-password/astro.md
Original file line number Diff line number Diff line change
Expand Up @@ -229,9 +229,9 @@ export async function POST(context: APIContext): Promise<Response> {
You can validate requests by checking `locals.user`. The field `user.username` is available since we defined the `getUserAttributes()` option. You can protect pages, such as `/`, by redirecting unauthenticated users to the login page.

```ts
const user = Astro.locals.user;
const user = context.locals.user;
if (!user) {
return Astro.redirect("/login");
return context.redirect("/login");
}

const username = user.username;
Expand All @@ -257,7 +257,7 @@ export async function POST(context: APIContext): Promise<Response> {
const sessionCookie = lucia.createBlankSessionCookie();
context.cookies.set(sessionCookie.name, sessionCookie.value, sessionCookie.attributes);

return Astro.redirect("/login");
return context.redirect("/login");
}
```

Expand Down

0 comments on commit 6fd5f7e

Please sign in to comment.