Skip to content

Commit eec938f

Browse files
committed
Check that the email isn't used during the registration process
1 parent d65286d commit eec938f

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

crates/handlers/src/views/register/password.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ use mas_policy::Policy;
2525
use mas_router::UrlBuilder;
2626
use mas_storage::{
2727
queue::{QueueJobRepositoryExt as _, SendEmailAuthenticationCodeJob},
28-
user::{UserEmailRepository, UserRepository},
28+
user::{UserEmailFilter, UserEmailRepository, UserRepository},
2929
BoxClock, BoxRepository, BoxRng, RepositoryAccess,
3030
};
3131
use mas_templates::{
@@ -194,6 +194,13 @@ pub(crate) async fn post(
194194
state.add_error_on_field(RegisterFormField::Email, FieldError::Required);
195195
} else if Address::from_str(&form.email).is_err() {
196196
state.add_error_on_field(RegisterFormField::Email, FieldError::Invalid);
197+
} else if repo
198+
.user_email()
199+
.count(UserEmailFilter::new().for_email(&form.email))
200+
.await?
201+
> 0
202+
{
203+
state.add_error_on_field(RegisterFormField::Email, FieldError::Exists);
197204
}
198205

199206
if form.password.is_empty() {

0 commit comments

Comments
 (0)