diff --git a/ProjectLighthouse.Localization/General.resx b/ProjectLighthouse.Localization/General.resx
index f3bd12b5..138736e8 100644
--- a/ProjectLighthouse.Localization/General.resx
+++ b/ProjectLighthouse.Localization/General.resx
@@ -54,4 +54,7 @@
Most recent photos
+
+ Email
+
\ No newline at end of file
diff --git a/ProjectLighthouse.Localization/StringLists/GeneralStrings.cs b/ProjectLighthouse.Localization/StringLists/GeneralStrings.cs
index 1b30afc9..edc3eb5f 100644
--- a/ProjectLighthouse.Localization/StringLists/GeneralStrings.cs
+++ b/ProjectLighthouse.Localization/StringLists/GeneralStrings.cs
@@ -4,6 +4,7 @@ public static class GeneralStrings
{
public static readonly TranslatableString Username = create("username");
public static readonly TranslatableString Password = create("password");
+ public static readonly TranslatableString Email = create("email");
public static readonly TranslatableString Register = create("register");
public static readonly TranslatableString ResetPassword = create("reset_password");
public static readonly TranslatableString ForgotPassword = create("forgot_password");
diff --git a/ProjectLighthouse.Servers.Website/Pages/LoginForm.cshtml b/ProjectLighthouse.Servers.Website/Pages/LoginForm.cshtml
index cedbbdc7..401ec447 100644
--- a/ProjectLighthouse.Servers.Website/Pages/LoginForm.cshtml
+++ b/ProjectLighthouse.Servers.Website/Pages/LoginForm.cshtml
@@ -41,9 +41,12 @@
@@ -75,9 +78,9 @@
}
-
-
- @Model.Translate(GeneralStrings.ForgotPassword)
-
-
+
+
+ @Model.Translate(GeneralStrings.ForgotPassword)
+
+
\ No newline at end of file
diff --git a/ProjectLighthouse.Servers.Website/Pages/LoginForm.cshtml.cs b/ProjectLighthouse.Servers.Website/Pages/LoginForm.cshtml.cs
index c751290e..8e9454b6 100644
--- a/ProjectLighthouse.Servers.Website/Pages/LoginForm.cshtml.cs
+++ b/ProjectLighthouse.Servers.Website/Pages/LoginForm.cshtml.cs
@@ -27,7 +27,7 @@ public class LoginForm : BaseLayout
{
if (string.IsNullOrWhiteSpace(username))
{
- this.Error = this.Translate(ErrorStrings.UsernameInvalid);
+ this.Error = ServerConfiguration.Instance.Mail.MailEnabled ? this.Translate(ErrorStrings.UsernameInvalid) : this.Translate(ErrorStrings.EmailInvalid);
return this.Page();
}
@@ -43,7 +43,23 @@ public class LoginForm : BaseLayout
return this.Page();
}
- User? user = await this.Database.Users.FirstOrDefaultAsync(u => u.Username == username);
+ User? user;
+
+ if (!ServerConfiguration.Instance.Mail.MailEnabled)
+ {
+ user = await this.Database.Users.FirstOrDefaultAsync(u => u.Username == username);
+ }
+ else
+ {
+ user = await this.Database.Users.FirstOrDefaultAsync(u => u.EmailAddress == username);
+ if (user == null)
+ {
+ User? noEmailUser = await this.Database.Users.FirstOrDefaultAsync(u => u.Username == username);
+ if (noEmailUser != null && noEmailUser.EmailAddress == null) user = noEmailUser;
+
+ }
+ }
+
if (user == null)
{
Logger.Warn($"User {username} failed to login on web due to invalid username", LogArea.Login);
diff --git a/ProjectLighthouse.Servers.Website/Pages/RegisterForm.cshtml b/ProjectLighthouse.Servers.Website/Pages/RegisterForm.cshtml
index 46ebd31a..56ccafa6 100644
--- a/ProjectLighthouse.Servers.Website/Pages/RegisterForm.cshtml
+++ b/ProjectLighthouse.Servers.Website/Pages/RegisterForm.cshtml
@@ -74,6 +74,12 @@
+
+
+
+
+
+
@if (ServerConfiguration.Instance.Captcha.CaptchaEnabled)
{
diff --git a/ProjectLighthouse.Servers.Website/Pages/UserSettingsPage.cshtml b/ProjectLighthouse.Servers.Website/Pages/UserSettingsPage.cshtml
index 5fe1bfc3..7acab753 100644
--- a/ProjectLighthouse.Servers.Website/Pages/UserSettingsPage.cshtml
+++ b/ProjectLighthouse.Servers.Website/Pages/UserSettingsPage.cshtml
@@ -67,7 +67,7 @@ function onSubmit(e){
@if (ServerConfiguration.Instance.Mail.MailEnabled && (Model.User == Model.ProfileUser || Model.User!.IsAdmin))
{
-
+
}
diff --git a/ProjectLighthouse.Tests.WebsiteTests/Tests/RegisterTests.cs b/ProjectLighthouse.Tests.WebsiteTests/Tests/RegisterTests.cs
index 7624ca83..be2561ca 100644
--- a/ProjectLighthouse.Tests.WebsiteTests/Tests/RegisterTests.cs
+++ b/ProjectLighthouse.Tests.WebsiteTests/Tests/RegisterTests.cs
@@ -28,6 +28,8 @@ public class RegisterTests : LighthouseWebTest
this.Driver.FindElement(By.Id("password")).SendKeys(password);
this.Driver.FindElement(By.Id("confirmPassword")).SendKeys(password);
+ this.Driver.FindElement(By.Id("age-checkbox")).Click();
+
this.Driver.FindElement(By.Id("submit")).Click();
User? user = await database.Users.FirstOrDefaultAsync(u => u.Username == username);
@@ -51,6 +53,8 @@ public class RegisterTests : LighthouseWebTest
this.Driver.FindElement(By.Id("password")).SendKeys(password);
this.Driver.FindElement(By.Id("confirmPassword")).SendKeys(password + "a");
+ this.Driver.FindElement(By.Id("age-checkbox")).Click();
+
this.Driver.FindElement(By.Id("submit")).Click();
User? user = await database.Users.FirstOrDefaultAsync(u => u.Username == username);
@@ -76,6 +80,8 @@ public class RegisterTests : LighthouseWebTest
this.Driver.FindElement(By.Id("password")).SendKeys(password);
this.Driver.FindElement(By.Id("confirmPassword")).SendKeys(password);
+ this.Driver.FindElement(By.Id("age-checkbox")).Click();
+
this.Driver.FindElement(By.Id("submit")).Click();
Assert.Contains("The username you've chosen is already taken.", this.Driver.PageSource);