Rework the flow of setting email from the website

This commit is contained in:
Slendy 2023-01-02 02:23:14 -06:00
commit cf1769ca77
No known key found for this signature in database
GPG key ID: 7288D68361B91428
8 changed files with 47 additions and 94 deletions

View file

@ -58,15 +58,20 @@ public class UserRequiredRedirectMiddleware : MiddlewareDBContext
return;
}
if (!user.EmailAddressVerified && ServerConfiguration.Instance.Mail.MailEnabled)
if (user.EmailAddress == null && ServerConfiguration.Instance.Mail.MailEnabled)
{
// The normal flow is for users to set their email during login so just force them to log out
if (user.EmailAddress == null)
if (!pathContains(ctx, "/login/setEmail"))
{
ctx.Response.Redirect("/logout");
ctx.Response.Redirect("/login/setEmail");
return;
}
await this.next(ctx);
return;
}
if (!user.EmailAddressVerified && ServerConfiguration.Instance.Mail.MailEnabled)
{
if (!pathContains(ctx, "/login/sendVerificationEmail", "/verifyEmail"))
{
ctx.Response.Redirect("/login/sendVerificationEmail");