Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: add error message for blocked email domains #436

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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');
};