From 7959c3187f90ad26f5f4a704537aa011e523e59e Mon Sep 17 00:00:00 2001 From: Sajarin M Date: Thu, 21 Sep 2023 10:25:30 +0530 Subject: [PATCH] Fix: change DUPLICATE_KEY_ID references (#1136) Co-authored-by: pilcrowOnPaper <80624252+pilcrowOnPaper@users.noreply.github.com> --- .auri/$33sxkjfs.md | 6 ++++++ documentation/content/main/basics/keys.md | 8 ++++---- documentation/content/main/basics/users.md | 2 +- packages/adapter-test/src/tests/main.ts | 2 +- 4 files changed, 12 insertions(+), 6 deletions(-) create mode 100644 .auri/$33sxkjfs.md diff --git a/.auri/$33sxkjfs.md b/.auri/$33sxkjfs.md new file mode 100644 index 000000000..1fd2f58ad --- /dev/null +++ b/.auri/$33sxkjfs.md @@ -0,0 +1,6 @@ +--- +package: "@lucia-auth/adapter-test" +type: "patch" +--- + +Fix `DUPLICATE_KEY_ID` to `AUTH_DUPLICATE_KEY_ID` in test name \ No newline at end of file diff --git a/documentation/content/main/basics/keys.md b/documentation/content/main/basics/keys.md index f046d56cf..69df8eba4 100644 --- a/documentation/content/main/basics/keys.md +++ b/documentation/content/main/basics/keys.md @@ -42,7 +42,7 @@ const key = await auth.useKey("github", githubUser.userId); ## Create keys -Keys can be created with [`Auth.createKey()`](/reference/lucia/interfaces/auth#createkey). This returns the newly created key, or throws `DUPLICATE_KEY_ID` if the key already exists. +Keys can be created with [`Auth.createKey()`](/reference/lucia/interfaces/auth#createkey). This returns the newly created key, or throws `AUTH_DUPLICATE_KEY_ID` if the key already exists. ```ts import { auth } from "./lucia.js"; @@ -56,7 +56,7 @@ try { password: "123456" }); } catch (e) { - if (e instanceof LuciaError && e.message === "DUPLICATE_KEY_ID") { + if (e instanceof LuciaError && e.message === "AUTH_DUPLICATE_KEY_ID") { // key already exists } // unexpected database errors @@ -78,7 +78,7 @@ const key = await auth.createKey({ In most cases, you want to create a key whenever you create (i.e. register) a new user. [`Auth.createUser()`](/reference/lucia/interfaces/auth#createuser) includes a parameter to define a key. `null` can be passed to `key` if you don't need to create a key. This preferable to using `Auth.createUser()` and `Auth.createKey()` consecutively as the user will not be created when the key already exists. -Similar to `Auth.createKey()`, it will throw `DUPLICATE_KEY_ID` if the key already exists. +Similar to `Auth.createKey()`, it will throw `AUTH_DUPLICATE_KEY_ID` if the key already exists. ```ts import { auth } from "./lucia.js"; @@ -94,7 +94,7 @@ try { // ... }); } catch (e) { - if (e instanceof LuciaError && e.message === "DUPLICATE_KEY_ID") { + if (e instanceof LuciaError && e.message === "AUTH_DUPLICATE_KEY_ID") { // key already exists } // provided user attributes violates database rules (e.g. unique constraint) diff --git a/documentation/content/main/basics/users.md b/documentation/content/main/basics/users.md index d9a5ee105..39d18cb82 100644 --- a/documentation/content/main/basics/users.md +++ b/documentation/content/main/basics/users.md @@ -60,7 +60,7 @@ try { } // expects `Lucia.DatabaseUserAttributes` }); } catch (e) { - if (e instanceof LuciaError && e.message === `DUPLICATE_KEY_ID`) { + if (e instanceof LuciaError && e.message === `AUTH_DUPLICATE_KEY_ID`) { // key already exists } // provided user attributes violates database rules (e.g. unique constraint) diff --git a/packages/adapter-test/src/tests/main.ts b/packages/adapter-test/src/tests/main.ts index 907374974..481de645c 100644 --- a/packages/adapter-test/src/tests/main.ts +++ b/packages/adapter-test/src/tests/main.ts @@ -47,7 +47,7 @@ export const testAdapter = async (adapter: Adapter, database: Database) => { assert.deepStrictEqual(storedUser, user); assert.deepStrictEqual(storedKey, key); }); - await test("Throws DUPLICATE_KEY_ID on duplicate key id", async () => { + await test("Throws AUTH_DUPLICATE_KEY_ID on duplicate key id", async () => { const user1 = database.generateUser(); const key1 = database.generateKey(user1.id); await User.insert(user1);