feat: login and logout

This commit is contained in:
Leon
2025-12-05 14:03:57 +08:00
parent b2cf39e731
commit 35938aaa13
5 changed files with 104 additions and 2 deletions

View File

@@ -2,6 +2,7 @@ package http
import (
"feedsystem_video_go/internal/account"
"feedsystem_video_go/internal/middleware"
"github.com/gin-gonic/gin"
"gorm.io/gorm"
@@ -21,6 +22,16 @@ func SetRouter(db *gorm.DB) *gin.Engine {
userGroup.POST("/findByID", userHandler.FindByID)
userGroup.POST("/findByUsername", userHandler.FindByUsername)
}
authGroup := r.Group("/auth")
{
authGroup.POST("/login", userHandler.Login)
}
protectedAuthGroup := authGroup.Group("")
protectedAuthGroup.Use(middleware.JWTAuth())
{
protectedAuthGroup.POST("/logout", userHandler.Logout)
}
return r
}