From 082e575f5e8feb97605f5ac9b69b49a14535e5ca Mon Sep 17 00:00:00 2001 From: Slendy Date: Fri, 16 Dec 2022 17:20:28 -0600 Subject: [PATCH] Potential fix for 2fa redirect loop --- .../Pages/TwoFactor/TwoFactorLoginPage.cshtml.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/ProjectLighthouse.Servers.Website/Pages/TwoFactor/TwoFactorLoginPage.cshtml.cs b/ProjectLighthouse.Servers.Website/Pages/TwoFactor/TwoFactorLoginPage.cshtml.cs index 6d3fc2e8..2391abb1 100644 --- a/ProjectLighthouse.Servers.Website/Pages/TwoFactor/TwoFactorLoginPage.cshtml.cs +++ b/ProjectLighthouse.Servers.Website/Pages/TwoFactor/TwoFactorLoginPage.cshtml.cs @@ -31,9 +31,11 @@ public class TwoFactorLoginPage : BaseLayout User? user = await this.Database.Users.Where(u => u.UserId == token.UserId).FirstOrDefaultAsync(); if (user == null) return this.Redirect("~/login"); - if (!user.IsTwoFactorSetup) return this.Redirect(this.RedirectUrl); + if (user.IsTwoFactorSetup) return this.Page(); - return this.Page(); + token.Verified = true; + await this.Database.SaveChangesAsync(); + return this.Redirect(this.RedirectUrl); } public async Task OnPost([FromForm] string? code, [FromForm] string? redirect, [FromForm] string? backup) @@ -54,6 +56,7 @@ public class TwoFactorLoginPage : BaseLayout { token.Verified = true; await this.Database.SaveChangesAsync(); + return this.Redirect(this.RedirectUrl); } // if both are null or neither are null, there should only be one at at time