no special characters when creating organization

Checks the organizations name for special chars using a regex
This commit is contained in:
Kevin
2023-12-16 12:57:44 -05:00
committed by GitHub
parent 1a5fd44a69
commit ff3f3012e0
+10
View File
@@ -18,6 +18,16 @@ const Organization = {
};
var slug = slugify(orgName, { lower: true });
const validNameRegex = /^[a-zA-Z0-9]+$/;
// Validate orgName against the regular expression
if (!validNameRegex.test(orgName)) {
return {
organization: null,
message: "Organization name contains invalid characters. Only alphanumeric characters are allowed.",
};
}
const existingBySlug = await this.get({ slug });
if (!!existingBySlug) {
const slugSeed = Math.floor(10000000 + Math.random() * 90000000);