moved randomString to lib
parent
6c3a79fb54
commit
5ae3083b43
|
@ -0,0 +1,9 @@
|
|||
export const randomString = function (length = 12) {
|
||||
let result = "";
|
||||
const characters = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
|
||||
const charactersLength = characters.length;
|
||||
for (let i = 0; i < length; i++) {
|
||||
result += characters.charAt(Math.floor(Math.random() * charactersLength));
|
||||
}
|
||||
return result;
|
||||
};
|
|
@ -5,21 +5,12 @@ import { authenticator } from "otplib";
|
|||
import { ErrorCode, isGoogleLoginEnabled, Session, verifyPassword } from "@lib/auth";
|
||||
import { symmetricDecrypt } from "@lib/crypto";
|
||||
import prisma from "@lib/prisma";
|
||||
import { randomString } from "@lib/random";
|
||||
import { isSAMLLoginEnabled, samlLoginUrl } from "@lib/saml";
|
||||
import slugify from "@lib/slugify";
|
||||
|
||||
import { IdentityProvider } from ".prisma/client";
|
||||
|
||||
function randomString(length = 12) {
|
||||
let result = "";
|
||||
const characters = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
|
||||
const charactersLength = characters.length;
|
||||
for (let i = 0; i < length; i++) {
|
||||
result += characters.charAt(Math.floor(Math.random() * charactersLength));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
async function authorize(credentials: any) {
|
||||
const user = await prisma.user.findUnique({
|
||||
where: {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { expect, test } from "@playwright/test";
|
||||
|
||||
import { randomString } from "./lib/testUtils";
|
||||
import { randomString } from "@lib/random";
|
||||
|
||||
test.beforeEach(async ({ page }) => {
|
||||
await page.goto("/event-types");
|
||||
|
|
|
@ -6,16 +6,6 @@ export function todo(title: string) {
|
|||
test.skip(title, () => {});
|
||||
}
|
||||
|
||||
export function randomString(length = 12) {
|
||||
let result = "";
|
||||
const characters = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
|
||||
const charactersLength = characters.length;
|
||||
for (let i = 0; i < length; i++) {
|
||||
result += characters.charAt(Math.floor(Math.random() * charactersLength));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
type Request = IncomingMessage & { body?: unknown };
|
||||
type RequestHandlerOptions = { req: Request; res: ServerResponse };
|
||||
type RequestHandler = (opts: RequestHandlerOptions) => void;
|
||||
|
|
Loading…
Reference in New Issue