summary refs log tree commit diff stats
path: root/authenticate/authenticate.go
diff options
context:
space:
mode:
authorChristian Krinitsin <mail@krinitsin.com>2025-04-25 00:10:25 +0200
committerChristian Krinitsin <mail@krinitsin.com>2025-04-25 00:10:25 +0200
commit3f299b3899d25c9bad5fdb34464a2bd853455b8f (patch)
tree4d106eefd3c67d4cffe01b15bd14bf2d641e7248 /authenticate/authenticate.go
parentb75c7c6a9a040af03ef8b498c88c267bfa00aaf4 (diff)
downloadshopping-list-3f299b3899d25c9bad5fdb34464a2bd853455b8f.tar.gz
shopping-list-3f299b3899d25c9bad5fdb34464a2bd853455b8f.zip
fix base_path
Diffstat (limited to 'authenticate/authenticate.go')
-rw-r--r--authenticate/authenticate.go18
1 files changed, 9 insertions, 9 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")
 }