mirror of
https://github.com/LBPUnion/ProjectLighthouse.git
synced 2025-05-20 16:22:27 +00:00
Login with email and confirm age on registration (#493)
* Implement login with email * Add confirm age checkbox to register page * Fix registration unit tests * Fix registration unit tests for real this time Co-authored-by: Dagg <32235163+daggintosh@users.noreply.github.com>
This commit is contained in:
parent
f46bd4fc87
commit
ee11798dc6
7 changed files with 45 additions and 10 deletions
|
@ -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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue