9447f16b82
* WIP * WIP * Type and migration fixes * Adds missing default import * Fixes import * Fixes tRPC imports in App Store * Migrate stripe helpers * WIP * Type fixes * Type fix? * Test fixes * Adds missing stripe packages * Moved queries to lib instead Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
27 lines
579 B
TypeScript
27 lines
579 B
TypeScript
import slugify from "@calcom/lib/slugify";
|
|
import prisma from "@calcom/prisma";
|
|
|
|
export async function checkRegularUsername(_username: string) {
|
|
const username = slugify(_username);
|
|
const premium = !!process.env.NEXT_PUBLIC_IS_E2E && username.length < 5;
|
|
|
|
const user = await prisma.user.findUnique({
|
|
where: { username },
|
|
select: {
|
|
username: true,
|
|
},
|
|
});
|
|
|
|
if (user) {
|
|
return {
|
|
available: false as const,
|
|
premium,
|
|
message: "A user exists with that username",
|
|
};
|
|
}
|
|
return {
|
|
available: true as const,
|
|
premium,
|
|
};
|
|
}
|