Skip to content

Commit

Permalink
fix: add error message for blocked email domains
Browse files Browse the repository at this point in the history
  • Loading branch information
onehassan committed Nov 9, 2023
1 parent eef9c80 commit affa71c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
4 changes: 3 additions & 1 deletion src/routes/signup/email-password.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ import { createUserAndSendVerificationEmail } from '@/utils/user/email-verificat
import { Joi, email, passwordInsert, registrationOptions } from '@/validation';

export const signUpEmailPasswordSchema = Joi.object({
email: email.required(),
email: email.required().messages({
'email-domain-not-allowed': 'This email is not allowed to sign up',
}),
password: passwordInsert.required(),
options: registrationOptions,
}).meta({ className: 'SignUpEmailPasswordSchema' });
Expand Down
6 changes: 3 additions & 3 deletions src/validation/validators/email.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ export const EmailValidator: CustomValidator = (email, helper) => {

// check if email is blocked
if (ENV.AUTH_ACCESS_CONTROL_BLOCKED_EMAIL_DOMAINS.includes(emailDomain)) {
return helper.error('Email is not valid');
return helper.error('email-domain-not-allowed');
}

if (ENV.AUTH_ACCESS_CONTROL_BLOCKED_EMAILS.includes(email)) {
return helper.error('Email is not valid');
return helper.error('email-domain-not-allowed');
}

// We've now checked the block list.
Expand All @@ -45,5 +45,5 @@ export const EmailValidator: CustomValidator = (email, helper) => {
return email;
}

return helper.error('Email is not valid');
return helper.error('email-domain-not-allowed');
};

0 comments on commit affa71c

Please sign in to comment.