Skip to content

Commit

Permalink
Merge pull request #94 from kschmelter13/patch-1
Browse files Browse the repository at this point in the history
no special characters when creating organization
  • Loading branch information
timothycarambat committed Dec 16, 2023
2 parents 1a5fd44 + ff3f301 commit 25d18aa
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions backend/models/organization.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 25d18aa

Please sign in to comment.