MCPcopy Create free account
hub / github.com/tbphp/gpt-load / Login

Method Login

internal/handler/handler.go:89–114  ·  view source on GitHub ↗

Login handles authentication verification

(c *gin.Context)

Source from the content-addressed store, hash-verified

87
88// Login handles authentication verification
89func (s *Server) Login(c *gin.Context) {
90 var req LoginRequest
91 if err := c.ShouldBindJSON(&req); err != nil {
92 c.JSON(http.StatusBadRequest, gin.H{
93 "success": false,
94 "message": i18n.Message(c, "auth.invalid_request"),
95 })
96 return
97 }
98
99 authConfig := s.config.GetAuthConfig()
100
101 isValid := subtle.ConstantTimeCompare([]byte(req.AuthKey), []byte(authConfig.Key)) == 1
102
103 if isValid {
104 c.JSON(http.StatusOK, LoginResponse{
105 Success: true,
106 Message: i18n.Message(c, "auth.authentication_successful"),
107 })
108 } else {
109 c.JSON(http.StatusUnauthorized, LoginResponse{
110 Success: false,
111 Message: i18n.Message(c, "auth.authentication_failed"),
112 })
113 }
114}
115
116// Health handles health check requests
117func (s *Server) Health(c *gin.Context) {

Callers

nothing calls this directly

Calls 2

MessageFunction · 0.92
GetAuthConfigMethod · 0.65

Tested by

no test coverage detected