Auth middleware with JWT
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user