added username check

This commit is contained in:
Daniel
2023-07-19 01:23:53 -04:00
parent ac2fab1476
commit 742e17351e
2 changed files with 21 additions and 2 deletions
+9
View File
@@ -20,6 +20,15 @@ export default async function updateUser(
status: 400,
};
const checkUsername = RegExp("^[a-z0-9_-]{3,31}$");
if (!checkUsername.test(user.username))
return {
response:
"Username has to be between 3-30 characters, no spaces and special characters are allowed.",
status: 400,
};
const userIsTaken = await prisma.user.findFirst({
where: {
id: { not: sessionUser.id },