From bab48abcfd0ac15019f672658c03cbfe9a726662 Mon Sep 17 00:00:00 2001 From: jvyden Date: Thu, 3 Mar 2022 17:24:21 -0500 Subject: [PATCH] Check if user's email address is already used --- ProjectLighthouse/Pages/RegisterForm.cshtml.cs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/ProjectLighthouse/Pages/RegisterForm.cshtml.cs b/ProjectLighthouse/Pages/RegisterForm.cshtml.cs index 5c371aa8..28a70ee3 100644 --- a/ProjectLighthouse/Pages/RegisterForm.cshtml.cs +++ b/ProjectLighthouse/Pages/RegisterForm.cshtml.cs @@ -54,6 +54,13 @@ public class RegisterForm : BaseLayout return this.Page(); } + if (ServerSettings.Instance.SMTPEnabled && + await this.Database.Users.FirstOrDefaultAsync(u => u.EmailAddress.ToLower() == emailAddress.ToLower()) != null) + { + this.Error = "The email address you've chosen is already taken."; + return this.Page(); + } + if (!await Request.CheckCaptchaValidity()) { this.Error = "You must complete the captcha correctly.";