From d029d4c0c42b7f2f76694bc4d701a7c1cb8e615f Mon Sep 17 00:00:00 2001 From: pilcrowOnPaper <80624252+pilcrowOnPaper@users.noreply.github.com> Date: Fri, 1 Sep 2023 08:04:40 +0900 Subject: [PATCH] Fix `existingUser` (#1051) --- documentation/content/guidebook/github-oauth/$astro.md | 2 +- documentation/content/guidebook/github-oauth/$express.md | 2 +- documentation/content/guidebook/github-oauth/$hono.md | 2 +- documentation/content/guidebook/github-oauth/$nextjs-app.md | 2 +- documentation/content/guidebook/github-oauth/$nextjs-pages.md | 2 +- documentation/content/guidebook/github-oauth/$nuxt.md | 2 +- documentation/content/guidebook/github-oauth/$solidstart.md | 2 +- documentation/content/guidebook/github-oauth/$sveltekit.md | 2 +- documentation/content/guidebook/github-oauth/index.md | 2 +- examples/astro/github-oauth/src/pages/login/github/callback.ts | 2 +- 10 files changed, 10 insertions(+), 10 deletions(-) diff --git a/documentation/content/guidebook/github-oauth/$astro.md b/documentation/content/guidebook/github-oauth/$astro.md index e485ea073..964c30c8d 100644 --- a/documentation/content/guidebook/github-oauth/$astro.md +++ b/documentation/content/guidebook/github-oauth/$astro.md @@ -213,7 +213,7 @@ export const get: APIRoute = async (context) => { ### Authenticate user with Lucia -You can check if the user has already registered with your app by checking `GithubUserAuth.existingUser`. Internally, this is done by checking if a [key](/basics/keys) with the Github user id already exists. +You can check if the user has already registered with your app by checking `GithubUserAuth.getExistingUser`. Internally, this is done by checking if a [key](/basics/keys) with the Github user id already exists. If they're a new user, you can create a new Lucia user (and key) with [`GithubUserAuth.createUser()`](/reference/oauth/interfaces#createuser). The type for `attributes` property is `Lucia.DatabaseUserAttributes`, which we added `github_username` to previously. You can access the Github user data with `GithubUserAuth.githubUser`, as well as the access tokens with `GithubUserAuth.githubTokens`. diff --git a/documentation/content/guidebook/github-oauth/$express.md b/documentation/content/guidebook/github-oauth/$express.md index 2d9c0a17c..fed078090 100644 --- a/documentation/content/guidebook/github-oauth/$express.md +++ b/documentation/content/guidebook/github-oauth/$express.md @@ -208,7 +208,7 @@ app.get("/login/github/callback", async (req, res) => { ### Authenticate user with Lucia -You can check if the user has already registered with your app by checking `GithubUserAuth.existingUser`. Internally, this is done by checking if a [key](/basics/keys) with the Github user id already exists. +You can check if the user has already registered with your app by checking `GithubUserAuth.getExistingUser`. Internally, this is done by checking if a [key](/basics/keys) with the Github user id already exists. If they're a new user, you can create a new Lucia user (and key) with [`GithubUserAuth.createUser()`](/reference/oauth/interfaces#createuser). The type for `attributes` property is `Lucia.DatabaseUserAttributes`, which we added `github_username` to previously. You can access the Github user data with `GithubUserAuth.githubUser`, as well as the access tokens with `GithubUserAuth.githubTokens`. diff --git a/documentation/content/guidebook/github-oauth/$hono.md b/documentation/content/guidebook/github-oauth/$hono.md index 89f74fe64..797666a72 100644 --- a/documentation/content/guidebook/github-oauth/$hono.md +++ b/documentation/content/guidebook/github-oauth/$hono.md @@ -185,7 +185,7 @@ app.get("/login/github/callback", async (context) => { ### Authenticate user with Lucia -You can check if the user has already registered with your app by checking `GithubUserAuth.existingUser`. Internally, this is done by checking if a [key](/basics/keys) with the Github user id already exists. +You can check if the user has already registered with your app by checking `GithubUserAuth.getExistingUser`. Internally, this is done by checking if a [key](/basics/keys) with the Github user id already exists. If they're a new user, you can create a new Lucia user (and key) with [`GithubUserAuth.createUser()`](/reference/oauth/interfaces#createuser). The type for `attributes` property is `Lucia.DatabaseUserAttributes`, which we added `github_username` to previously. You can access the Github user data with `GithubUserAuth.githubUser`, as well as the access tokens with `GithubUserAuth.githubTokens`. diff --git a/documentation/content/guidebook/github-oauth/$nextjs-app.md b/documentation/content/guidebook/github-oauth/$nextjs-app.md index ef1af2ceb..4dfd024e6 100644 --- a/documentation/content/guidebook/github-oauth/$nextjs-app.md +++ b/documentation/content/guidebook/github-oauth/$nextjs-app.md @@ -259,7 +259,7 @@ export const GET = async (request: NextRequest) => { ### Authenticate user with Lucia -You can check if the user has already registered with your app by checking `GithubUserAuth.existingUser`. Internally, this is done by checking if a [key](/basics/keys) with the Github user id already exists. +You can check if the user has already registered with your app by checking `GithubUserAuth.getExistingUser`. Internally, this is done by checking if a [key](/basics/keys) with the Github user id already exists. If they're a new user, you can create a new Lucia user (and key) with [`GithubUserAuth.createUser()`](/reference/oauth/interfaces#createuser). The type for `attributes` property is `Lucia.DatabaseUserAttributes`, which we added `github_username` to previously. You can access the Github user data with `GithubUserAuth.githubUser`, as well as the access tokens with `GithubUserAuth.githubTokens`. diff --git a/documentation/content/guidebook/github-oauth/$nextjs-pages.md b/documentation/content/guidebook/github-oauth/$nextjs-pages.md index ff8e9f6e0..9ec78d516 100644 --- a/documentation/content/guidebook/github-oauth/$nextjs-pages.md +++ b/documentation/content/guidebook/github-oauth/$nextjs-pages.md @@ -232,7 +232,7 @@ export default handler; ### Authenticate user with Lucia -You can check if the user has already registered with your app by checking `GithubUserAuth.existingUser`. Internally, this is done by checking if a [key](/basics/keys) with the Github user id already exists. +You can check if the user has already registered with your app by checking `GithubUserAuth.getExistingUser`. Internally, this is done by checking if a [key](/basics/keys) with the Github user id already exists. If they're a new user, you can create a new Lucia user (and key) with [`GithubUserAuth.createUser()`](/reference/oauth/interfaces#createuser). The type for `attributes` property is `Lucia.DatabaseUserAttributes`, which we added `github_username` to previously. You can access the Github user data with `GithubUserAuth.githubUser`, as well as the access tokens with `GithubUserAuth.githubTokens`. diff --git a/documentation/content/guidebook/github-oauth/$nuxt.md b/documentation/content/guidebook/github-oauth/$nuxt.md index 0f70d6f5a..55f4b0d72 100644 --- a/documentation/content/guidebook/github-oauth/$nuxt.md +++ b/documentation/content/guidebook/github-oauth/$nuxt.md @@ -231,7 +231,7 @@ export default defineEventHandler(async (event) => { ### Authenticate user with Lucia -You can check if the user has already registered with your app by checking `GithubUserAuth.existingUser`. Internally, this is done by checking if a [key](/basics/keys) with the Github user id already exists. +You can check if the user has already registered with your app by checking `GithubUserAuth.getExistingUser`. Internally, this is done by checking if a [key](/basics/keys) with the Github user id already exists. If they're a new user, you can create a new Lucia user (and key) with [`GithubUserAuth.createUser()`](/reference/oauth/interfaces#createuser). The type for `attributes` property is `Lucia.DatabaseUserAttributes`, which we added `github_username` to previously. You can access the Github user data with `GithubUserAuth.githubUser`, as well as the access tokens with `GithubUserAuth.githubTokens`. diff --git a/documentation/content/guidebook/github-oauth/$solidstart.md b/documentation/content/guidebook/github-oauth/$solidstart.md index e6c0cf221..1889644f1 100644 --- a/documentation/content/guidebook/github-oauth/$solidstart.md +++ b/documentation/content/guidebook/github-oauth/$solidstart.md @@ -246,7 +246,7 @@ export const GET = async (event: APIEvent) => { ### Authenticate user with Lucia -You can check if the user has already registered with your app by checking `GithubUserAuth.existingUser`. Internally, this is done by checking if a [key](/basics/keys) with the Github user id already exists. +You can check if the user has already registered with your app by checking `GithubUserAuth.getExistingUser`. Internally, this is done by checking if a [key](/basics/keys) with the Github user id already exists. If they're a new user, you can create a new Lucia user (and key) with [`GithubUserAuth.createUser()`](/reference/oauth/interfaces#createuser). The type for `attributes` property is `Lucia.DatabaseUserAttributes`, which we added `github_username` to previously. You can access the Github user data with `GithubUserAuth.githubUser`, as well as the access tokens with `GithubUserAuth.githubTokens`. diff --git a/documentation/content/guidebook/github-oauth/$sveltekit.md b/documentation/content/guidebook/github-oauth/$sveltekit.md index 40bd8fb36..16a54cc62 100644 --- a/documentation/content/guidebook/github-oauth/$sveltekit.md +++ b/documentation/content/guidebook/github-oauth/$sveltekit.md @@ -232,7 +232,7 @@ export const GET = async ({ url, cookies, locals }) => { ### Authenticate user with Lucia -You can check if the user has already registered with your app by checking `GithubUserAuth.existingUser`. Internally, this is done by checking if a [key](/basics/keys) with the Github user id already exists. +You can check if the user has already registered with your app by checking `GithubUserAuth.getExistingUser`. Internally, this is done by checking if a [key](/basics/keys) with the Github user id already exists. If they're a new user, you can create a new Lucia user (and key) with [`GithubUserAuth.createUser()`](/reference/oauth/interfaces#createuser). The type for `attributes` property is `Lucia.DatabaseUserAttributes`, which we added `github_username` to previously. You can access the Github user data with `GithubUserAuth.githubUser`, as well as the access tokens with `GithubUserAuth.githubTokens`. diff --git a/documentation/content/guidebook/github-oauth/index.md b/documentation/content/guidebook/github-oauth/index.md index 4714eccfb..c751b9f93 100644 --- a/documentation/content/guidebook/github-oauth/index.md +++ b/documentation/content/guidebook/github-oauth/index.md @@ -222,7 +222,7 @@ get("/login/github/callback", async (request: Request) => { ### Authenticate user with Lucia -You can check if the user has already registered with your app by checking `GithubUserAuth.existingUser`. Internally, this is done by checking if a [key](/basics/keys) with the Github user id already exists. +You can check if the user has already registered with your app by checking `GithubUserAuth.getExistingUser`. Internally, this is done by checking if a [key](/basics/keys) with the Github user id already exists. If they're a new user, you can create a new Lucia user (and key) with [`GithubUserAuth.createUser()`](/reference/oauth/interfaces#createuser). The type for `attributes` property is `Lucia.DatabaseUserAttributes`, which we added `github_username` to previously. You can access the Github user data with `GithubUserAuth.githubUser`, as well as the access tokens with `GithubUserAuth.githubTokens`. diff --git a/examples/astro/github-oauth/src/pages/login/github/callback.ts b/examples/astro/github-oauth/src/pages/login/github/callback.ts index d64aa80c5..759ab63b7 100644 --- a/examples/astro/github-oauth/src/pages/login/github/callback.ts +++ b/examples/astro/github-oauth/src/pages/login/github/callback.ts @@ -8,7 +8,7 @@ export const get: APIRoute = async (context) => { if (session) { return context.redirect("/", 302); // redirect to profile page } - const storedState = context.cookies.get("github_oauth_state").value; + const storedState = context.cookies.get("github_oauth_state")?.value; const state = context.url.searchParams.get("state"); const code = context.url.searchParams.get("code"); // validate state