hi-server/internal/handler/auth/userLoginHandler.go
EUForest 3ca471f58c refactor(auth): move captcha verification from handler to logic layer
- Remove duplicate captcha verification from user login handler
- Remove duplicate captcha verification from user register handler
- Remove duplicate captcha verification from password reset handler
- Remove duplicate captcha verification from phone login handler
- Remove duplicate captcha verification from phone register handler
- Update phone reset password handler structure
- Improve separation of concerns between handler and logic layers
- Handlers now only handle HTTP request/response, logic handles business rules
2026-03-09 22:56:07 +08:00

31 lines
767 B
Go

package auth
import (
"github.com/gin-gonic/gin"
"github.com/perfect-panel/server/internal/logic/auth"
"github.com/perfect-panel/server/internal/svc"
"github.com/perfect-panel/server/internal/types"
"github.com/perfect-panel/server/pkg/result"
)
// User login
func UserLoginHandler(svcCtx *svc.ServiceContext) func(c *gin.Context) {
return func(c *gin.Context) {
var req types.UserLoginRequest
_ = c.ShouldBind(&req)
// get client ip
req.IP = c.ClientIP()
req.UserAgent = c.Request.UserAgent()
validateErr := svcCtx.Validate(&req)
if validateErr != nil {
result.ParamErrorResult(c, validateErr)
return
}
l := auth.NewUserLoginLogic(c.Request.Context(), svcCtx)
resp, err := l.UserLogin(&req)
result.HttpResult(c, resp, err)
}
}