Add setup-flow

This commit is contained in:
2026-03-21 03:12:13 +01:00
parent 80a2f662dc
commit dd044cf5d0
17 changed files with 519 additions and 37 deletions

View File

@@ -22,13 +22,11 @@ func AuthMiddleware() gin.HandlerFunc {
var tokenString string
// 🔥 1. Try cookie first (NEW)
cookie, err := c.Cookie("auth_token")
if err == nil && cookie != "" {
tokenString = cookie
}
// 🔥 2. Fallback to Authorization header (for API tools / future SPA)
if tokenString == "" {
authHeader := c.GetHeader("Authorization")
@@ -40,13 +38,11 @@ func AuthMiddleware() gin.HandlerFunc {
}
}
// ❌ No token at all
if tokenString == "" {
abortUnauthorized(c)
return
}
// 🔐 Parse JWT
claims := &Claims{}
token, err := jwt.ParseWithClaims(tokenString, claims, func(token *jwt.Token) (interface{}, error) {
if _, ok := token.Method.(*jwt.SigningMethodHMAC); !ok {