refactor(web): make a separate auth middlewares for server

also slightly change api auth middleware
This commit is contained in:
2025-01-07 04:32:49 +03:00
parent 8b417dc623
commit 2228dc5f14
4 changed files with 20 additions and 10 deletions
+16
View File
@@ -0,0 +1,16 @@
package server
import (
"net/http"
"github.com/gin-gonic/gin"
)
func middlewareAuth(c *gin.Context) {
user_id := c.GetString("user_id")
if user_id == "" {
c.Redirect(http.StatusSeeOther, "/")
return
}
c.Next()
}