mirror of
https://github.com/LBPUnion/ProjectLighthouse.git
synced 2025-07-24 14:11:29 +00:00
Change login UI and improve email setup flow (#619)
* Rework login UI design and change email setup flow * Remove unused middleware * Fix button not lining up with input fields
This commit is contained in:
parent
20b2ef5700
commit
7d187ee982
11 changed files with 207 additions and 179 deletions
|
@ -1,5 +1,7 @@
|
|||
#nullable enable
|
||||
using LBPUnion.ProjectLighthouse.Configuration;
|
||||
using LBPUnion.ProjectLighthouse.Helpers;
|
||||
using LBPUnion.ProjectLighthouse.PlayerData;
|
||||
using LBPUnion.ProjectLighthouse.PlayerData.Profiles;
|
||||
using LBPUnion.ProjectLighthouse.PlayerData.Profiles.Email;
|
||||
using LBPUnion.ProjectLighthouse.Servers.Website.Pages.Layouts;
|
||||
|
@ -19,9 +21,6 @@ public class CompleteEmailVerificationPage : BaseLayout
|
|||
{
|
||||
if (!ServerConfiguration.Instance.Mail.MailEnabled) return this.NotFound();
|
||||
|
||||
User? user = this.Database.UserFromWebRequest(this.Request);
|
||||
if (user == null) return this.Redirect("~/login");
|
||||
|
||||
EmailVerificationToken? emailVerifyToken = await this.Database.EmailVerificationTokens.FirstOrDefaultAsync(e => e.EmailToken == token);
|
||||
if (emailVerifyToken == null)
|
||||
{
|
||||
|
@ -29,6 +28,8 @@ public class CompleteEmailVerificationPage : BaseLayout
|
|||
return this.Page();
|
||||
}
|
||||
|
||||
User user = await this.Database.Users.FirstAsync(u => u.UserId == emailVerifyToken.UserId);
|
||||
|
||||
if (DateTime.Now > emailVerifyToken.ExpiresAt)
|
||||
{
|
||||
this.Error = "This token has expired";
|
||||
|
@ -44,9 +45,27 @@ public class CompleteEmailVerificationPage : BaseLayout
|
|||
this.Database.EmailVerificationTokens.Remove(emailVerifyToken);
|
||||
|
||||
user.EmailAddressVerified = true;
|
||||
|
||||
await this.Database.SaveChangesAsync();
|
||||
|
||||
return this.Page();
|
||||
if (user.Password != null) return this.Page();
|
||||
|
||||
// if user's account was created automatically
|
||||
WebToken webToken = new()
|
||||
{
|
||||
ExpiresAt = DateTime.Now.AddDays(7),
|
||||
Verified = true,
|
||||
UserId = user.UserId,
|
||||
UserToken = CryptoHelper.GenerateAuthToken(),
|
||||
};
|
||||
user.PasswordResetRequired = true;
|
||||
this.Database.WebTokens.Add(webToken);
|
||||
await this.Database.SaveChangesAsync();
|
||||
this.Response.Cookies.Append("LighthouseToken",
|
||||
webToken.UserToken,
|
||||
new CookieOptions
|
||||
{
|
||||
Expires = DateTimeOffset.Now.AddDays(7),
|
||||
});
|
||||
return this.Redirect("/passwordReset");
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue