Fix a panic bug

This commit is contained in:
James Mills 2023-08-28 00:44:35 +10:00
parent e827f0cb23
commit f8c888d6b0
No known key found for this signature in database
GPG key ID: AC4C014F1440EBD6

View file

@ -78,7 +78,9 @@ func AuthMiddleware(c *gin.Context, db *gorm.DB, cfg *config.Config) {
return return
} }
SetTokenCookie(c, token) SetTokenCookie(c, token)
} else { return
}
if database.CountAdmins(db) < 1 { if database.CountAdmins(db) < 1 {
c.Redirect(http.StatusFound, "/registration") c.Redirect(http.StatusFound, "/registration")
} else { } else {
@ -87,7 +89,6 @@ func AuthMiddleware(c *gin.Context, db *gorm.DB, cfg *config.Config) {
c.Abort() c.Abort()
return return
} }
}
// Create a new token if the old one is about to expire // Create a new token if the old one is about to expire
if time.Now().Add(12 * time.Hour).After(claims.ExpiresAt.Time) { if time.Now().Add(12 * time.Hour).After(claims.ExpiresAt.Time) {