[CAL-409] Prevents usernames with special characters (#668)

This commit is contained in:
Omar López authored and GitHub committed 2021-09-18 00:08:02 +01:00
1 parent dd9f5fe791
commit f6005b8c70
2 files changed
+8 -5

No files matched your search

+7 -4
View File
@@ -1,13 +1,16 @@
import prisma from "../../../lib/prisma";
import { hashPassword } from "../../../lib/auth";
import { hashPassword } from "@lib/auth";
import prisma from "@lib/prisma";
import slugify from "@lib/slugify";
import { NextApiRequest, NextApiResponse } from "next";
export default async function handler(req, res) {
export default async function handler(req: NextApiRequest, res: NextApiResponse) {
if (req.method !== "POST") {
return;
}
const data = req.body;
const { username, email, password } = data;
const { email, password } = data;
const username = slugify(data.username);
if (!username) {
res.status(422).json({ message: "Invalid username" });