mirror of
https://github.com/LBPUnion/ProjectLighthouse.git
synced 2025-05-17 15:22:26 +00:00
Make 2FA redirect highest priority
This commit is contained in:
parent
fb90371ad1
commit
461de3a299
1 changed files with 13 additions and 12 deletions
|
@ -11,7 +11,7 @@ public class UserRequiredRedirectMiddleware : MiddlewareDBContext
|
|||
public UserRequiredRedirectMiddleware(RequestDelegate next) : base(next)
|
||||
{ }
|
||||
|
||||
public override async Task InvokeAsync(HttpContext ctx, Database database)
|
||||
public override async Task InvokeAsync(HttpContext ctx, Database.Database database)
|
||||
{
|
||||
WebToken? token = database.WebTokenFromRequest(ctx.Request);
|
||||
if (token == null || pathContains(ctx, "/logout"))
|
||||
|
@ -34,6 +34,18 @@ public class UserRequiredRedirectMiddleware : MiddlewareDBContext
|
|||
return;
|
||||
}
|
||||
|
||||
if (!token.Verified && ServerConfiguration.Instance.TwoFactorConfiguration.TwoFactorEnabled)
|
||||
{
|
||||
if (!pathContains(ctx, "/2fa"))
|
||||
{
|
||||
ctx.Response.Redirect("/2fa");
|
||||
return;
|
||||
}
|
||||
|
||||
await this.next(ctx);
|
||||
return;
|
||||
}
|
||||
|
||||
if (user.PasswordResetRequired)
|
||||
{
|
||||
if (!pathContains(ctx, "/passwordResetRequired", "/passwordReset"))
|
||||
|
@ -77,17 +89,6 @@ public class UserRequiredRedirectMiddleware : MiddlewareDBContext
|
|||
return;
|
||||
}
|
||||
|
||||
if (!token.Verified && ServerConfiguration.Instance.TwoFactorConfiguration.TwoFactorEnabled)
|
||||
{
|
||||
if (!pathContains(ctx, "/2fa"))
|
||||
{
|
||||
ctx.Response.Redirect("/2fa");
|
||||
return;
|
||||
}
|
||||
await this.next(ctx);
|
||||
return;
|
||||
}
|
||||
|
||||
await this.next(ctx);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue