Skip to content

Commit

Permalink
Fix: change DUPLICATE_KEY_ID references (#1136)
Browse files Browse the repository at this point in the history
Co-authored-by: pilcrowOnPaper <[email protected]>
  • Loading branch information
Sajarin-M and pilcrowonpaper authored Sep 21, 2023
1 parent 8237d54 commit 7959c31
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 6 deletions.
6 changes: 6 additions & 0 deletions .auri/$33sxkjfs.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
package: "@lucia-auth/adapter-test"
type: "patch"
---

Fix `DUPLICATE_KEY_ID` to `AUTH_DUPLICATE_KEY_ID` in test name
8 changes: 4 additions & 4 deletions documentation/content/main/basics/keys.md
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -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
Expand All @@ -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";
Expand All @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion documentation/content/main/basics/users.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion packages/adapter-test/src/tests/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 7959c31

Please sign in to comment.