From f8c888d6b069de3df67d327cb0a64c374af2da0f Mon Sep 17 00:00:00 2001 From: James Mills <1290234+prologic@users.noreply.github.com> Date: Mon, 28 Aug 2023 00:44:35 +1000 Subject: [PATCH] Fix a panic bug --- views/auth.go | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/views/auth.go b/views/auth.go index 2308fe9..f1ab5f3 100644 --- a/views/auth.go +++ b/views/auth.go @@ -78,15 +78,16 @@ func AuthMiddleware(c *gin.Context, db *gorm.DB, cfg *config.Config) { return } SetTokenCookie(c, token) - } else { - if database.CountAdmins(db) < 1 { - c.Redirect(http.StatusFound, "/registration") - } else { - c.Redirect(http.StatusFound, "/signin") - } - c.Abort() return } + + if database.CountAdmins(db) < 1 { + c.Redirect(http.StatusFound, "/registration") + } else { + c.Redirect(http.StatusFound, "/signin") + } + c.Abort() + return } // Create a new token if the old one is about to expire