Skip to content

Commit 11e3f15

Browse files
committed
fix: set the length of generated user ids shorter
1 parent 5aab8e5 commit 11e3f15

File tree

4 files changed

+11
-4
lines changed

4 files changed

+11
-4
lines changed

key/admin.key.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import fastifyPlugin from "fastify-plugin";
22
import config from "../config.js";
33
import { writeFileSync } from "fs";
4-
import { createId } from "@paralleldrive/cuid2";
4+
import { init } from "@paralleldrive/cuid2";
55
import { createHash } from "../utils/credential.js";
66
import * as crypto from "crypto";
77
import { eq } from "drizzle-orm";
@@ -29,6 +29,7 @@ const setupAdminKey = async function (fastify) {
2929
}
3030

3131
//Create the default admin user in the Database, set the password to a random UUID as a placeholder
32+
const createId = init({ length: 10 });
3233
const uuid = createId();
3334
const adminPwd = generatePassword();
3435
const hashPwd = await createHash(adminPwd);

services/admin/create.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { createHash } from "../../utils/credential.js";
22
import { randomUUID } from "crypto";
3-
import { createId } from "@paralleldrive/cuid2";
3+
import { init } from "@paralleldrive/cuid2";
44
import { eq } from "drizzle-orm";
55

66
const validateStatus = (value, fieldName) => {
@@ -12,6 +12,8 @@ const validateStatus = (value, fieldName) => {
1212
}
1313
};
1414

15+
const createId = init({ length: 10 });
16+
1517
export const createUserHandler = async function (request, reply) {
1618
const { data } = request.body;
1719

services/auth/registration.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
import { createHash, secureCookie } from "../../utils/credential.js";
22
import { randomUUID } from "crypto";
3-
import { createId } from "@paralleldrive/cuid2";
3+
import { init } from "@paralleldrive/cuid2";
44
import { makeAccesstoken, makeRefreshtoken } from "../../utils/jwt.js";
55
import config from "../../config.js";
66
import { refreshCookie } from "../../utils/cookies.js";
77
import { eq } from "drizzle-orm";
88

9+
const createId = init({ length: 10 });
10+
911
export const registrationHandler = async function (request, reply) {
1012
const {
1113
data: { type, attributes },

services/webAuthn/registrationOptions.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
import config from "../../config.js";
2-
import { createId } from "@paralleldrive/cuid2";
2+
import { init } from "@paralleldrive/cuid2";
33
import { createHash } from "../../utils/credential.js";
44
import crypto from "crypto";
55
import { generateRegistrationOptions } from "@simplewebauthn/server";
66

7+
const createId = init({ length: 10 });
8+
79
export const registrationOptionsHandler = async function (request, reply) {
810
try {
911
const { name: userName, email: userEmail } = request.body;

0 commit comments

Comments
 (0)