diff --git a/client/src/components/modal/brief-info.tsx b/client/src/components/modal/brief-info.tsx index 78c394d..718a2cd 100644 --- a/client/src/components/modal/brief-info.tsx +++ b/client/src/components/modal/brief-info.tsx @@ -26,6 +26,11 @@ const BriefInfo: React.FC = ({ registerData, setRegisterData const handleInputChange = useCallback((e: React.ChangeEvent) => { const { name, value } = e.target; + const specialCharRegex = /[!@#$%^&*()_+\-=\[\]{};':"\\|,.<>\/?]/; + if (specialCharRegex.test(value)) { + return toast.warning('Special characters not allowed.'); + } + setRegisterData(prevState => ({ ...prevState, [name]: value diff --git a/server/routes/auth.js b/server/routes/auth.js index 9852693..fba5701 100644 --- a/server/routes/auth.js +++ b/server/routes/auth.js @@ -9,9 +9,9 @@ module.exports = async function (fastify, opts) { email: { type: 'string', format: 'email', minLength: 1 }, password: { type: 'string', minLength: 6 }, avatar: { type: 'string', nullable: true }, - username: { type: 'string', minLength: 1 }, - first_name: { type: 'string', minLength: 1 }, - last_name: { type: 'string', minLength: 1 } + username: { type: 'string', minLength: 1, pattern: '^[a-zA-Z0-9]+$' }, + first_name: { type: 'string', minLength: 1, pattern: '^[a-zA-Z0-9]+$' }, + last_name: { type: 'string', minLength: 1, pattern: '^[a-zA-Z0-9]+$' } }, required: ['email', 'password', 'username', 'first_name', 'last_name'] }