From 4f601550a2e8ad45e9a96146fa3003101100559d Mon Sep 17 00:00:00 2001 From: jvyden Date: Thu, 3 Mar 2022 17:18:31 -0500 Subject: [PATCH] Assert if email address already verified on SendVerificationEmailPage --- .../Pages/SendVerificationEmailPage.cshtml.cs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/ProjectLighthouse/Pages/SendVerificationEmailPage.cshtml.cs b/ProjectLighthouse/Pages/SendVerificationEmailPage.cshtml.cs index f02a2244..a6dc791a 100644 --- a/ProjectLighthouse/Pages/SendVerificationEmailPage.cshtml.cs +++ b/ProjectLighthouse/Pages/SendVerificationEmailPage.cshtml.cs @@ -20,6 +20,18 @@ public class SendVerificationEmailPage : BaseLayout User? user = this.Database.UserFromWebRequest(this.Request); if (user == null) return this.Redirect("/login"); + // `using` weirdness here. I tried to fix it, but I couldn't. + // The user should never see this page once they've been verified, so assert here. + System.Diagnostics.Debug.Assert(!user.EmailAddressVerified); + + // Othewise, on a release build, just silently redirect them to the landing page. + #if !DEBUG + if (user.EmailAddressVerified) + { + return this.Redirect("/"); + } + #endif + EmailVerificationToken verifyToken = new() { UserId = user.UserId,