mirror of
https://github.com/ordinary-dev/phoenix
synced 2024-09-20 03:40:29 +05:00
Fix a panic bug
This commit is contained in:
parent
e827f0cb23
commit
f8c888d6b0
|
@ -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) {
|
||||||
|
|
Loading…
Reference in a new issue