Skip to content
Snippets Groups Projects
Unverified Commit e909b25b authored by Sean Hatfield's avatar Sean Hatfield Committed by GitHub
Browse files

[FEAT] Prisma injection validation (#1874)

check all prisma models/model usage and patch any potential sql injection vulns
parent 9b86bbd2
No related branches found
No related tags found
No related merge requests found
......@@ -22,6 +22,15 @@ const User = {
throw new Error(e.message);
}
},
role: (role = "default") => {
const VALID_ROLES = ["default", "admin", "manager"];
if (!VALID_ROLES.includes(role)) {
throw new Error(
`Invalid role. Allowed roles are: ${VALID_ROLES.join(", ")}`
);
}
return String(role);
},
},
// validations for the above writable fields.
......@@ -52,7 +61,7 @@ const User = {
data: {
username: this.validations.username(username),
password: hashedPassword,
role: String(role),
role: this.validations.role(role),
},
});
return { user: this.filterFields(user), error: null };
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment