Skip to content

Commit 6fd5f7e

Browse files
authored
correct the code snippet in doc (#1584)
1 parent 019b27e commit 6fd5f7e

File tree

1 file changed

+3
-3
lines changed
  • docs/pages/tutorials/username-and-password

1 file changed

+3
-3
lines changed

docs/pages/tutorials/username-and-password/astro.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -229,9 +229,9 @@ export async function POST(context: APIContext): Promise<Response> {
229229
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.
230230

231231
```ts
232-
const user = Astro.locals.user;
232+
const user = context.locals.user;
233233
if (!user) {
234-
return Astro.redirect("/login");
234+
return context.redirect("/login");
235235
}
236236

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

260-
return Astro.redirect("/login");
260+
return context.redirect("/login");
261261
}
262262
```
263263

0 commit comments

Comments
 (0)