Auth middleware with JWT

This commit is contained in:
Leons Aleksandrovs
2025-07-06 18:13:26 +03:00
parent 3003a961b6
commit d18f9f9706
5 changed files with 90 additions and 0 deletions
+7
View File
@@ -2,6 +2,7 @@ package routes
import (
"backend/controllers/user"
"backend/middleware"
"github.com/gin-gonic/gin"
)
@@ -13,5 +14,11 @@ func SetupRoutes() *gin.Engine {
r.POST("/register", user.Register)
r.POST("/login", user.Login)
// Authenticated routes middleware/group
auth := r.Group("/")
auth.Use(middleware.IsAuthenticated())
auth.GET("/info", user.TokenInfo) // Route to check if user is authenticated
return r
}