diff options
| -rw-r--r-- | authenticate/authenticate.go | 18 | ||||
| -rw-r--r-- | models/database.go | 6 |
2 files changed, 12 insertions, 12 deletions
diff --git a/authenticate/authenticate.go b/authenticate/authenticate.go index 8862313..7ca1472 100644 --- a/authenticate/authenticate.go +++ b/authenticate/authenticate.go @@ -20,13 +20,13 @@ func CheckAuth(c *gin.Context) { token_session := session.Get("token") if token_session == nil { - c.Redirect(http.StatusFound, "/login") + c.Redirect(http.StatusFound, models.BasePath() + "/login") return } token_string, ok := token_session.(string) if !ok { - c.Redirect(http.StatusFound, "/login") + c.Redirect(http.StatusFound, models.BasePath() + "/login") return } @@ -38,19 +38,19 @@ func CheckAuth(c *gin.Context) { }) if err != nil || !token.Valid { - c.Redirect(http.StatusFound, "/login") + c.Redirect(http.StatusFound, models.BasePath() + "/login") c.Error(err) return } claims, ok := token.Claims.(jwt.MapClaims) if !ok { - c.Redirect(http.StatusFound, "/login") + c.Redirect(http.StatusFound, models.BasePath() + "/login") return } if float64(time.Now().Unix()) > claims["exp"].(float64) { - c.Redirect(http.StatusFound, "/login") + c.Redirect(http.StatusFound, models.BasePath() + "/login") return } @@ -61,7 +61,7 @@ func CheckAuth(c *gin.Context) { First(&list). Error if err != nil { - c.Redirect(http.StatusFound, "/login") + c.Redirect(http.StatusFound, models.BasePath() + "/login") return } @@ -136,7 +136,7 @@ func LoginPOST(c *gin.Context) { session.Set("token", token) session.Save() - c.Redirect(http.StatusFound, "/") + c.Redirect(http.StatusFound, models.BasePath() + "/") } func RegisterGET(c *gin.Context) { @@ -222,12 +222,12 @@ func RegisterPOST(c *gin.Context) { return } - c.Redirect(http.StatusFound, "/login") + c.Redirect(http.StatusFound, models.BasePath() + "/login") } func Logout(c *gin.Context) { session := sessions.Default(c) session.Delete("token") session.Save() - c.Redirect(http.StatusFound, "/login") + c.Redirect(http.StatusFound, models.BasePath() + "/login") } diff --git a/models/database.go b/models/database.go index ffc8a47..4998bde 100644 --- a/models/database.go +++ b/models/database.go @@ -42,9 +42,9 @@ func ConnectDatabase() { func BasePath() string { basePath := os.Getenv("BASE_PATH") - if basePath == "" { - basePath = "/" - } + // if basePath == "" { + // basePath = "/" + // } return basePath } |