MCPcopy Create free account
hub / github.com/QuantumNous/new-api / writeAuthSessionError

Function writeAuthSessionError

controller/auth_session.go:164–176  ·  view source on GitHub ↗
(c *gin.Context, err error)

Source from the content-addressed store, hash-verified

162}
163
164func writeAuthSessionError(c *gin.Context, err error) {
165 status, code := service.AuthSessionErrorCode(err)
166 if errors.Is(err, gorm.ErrRecordNotFound) {
167 status, code = http.StatusUnauthorized, "AUTH_UNAUTHORIZED"
168 }
169 if status == http.StatusInternalServerError {
170 // The response body only carries the generic AUTH_INTERNAL_ERROR
171 // code; without this log the underlying Redis/database/session
172 // failure is indistinguishable from the client side.
173 logger.LogError(c.Request.Context(), fmt.Sprintf("auth session internal error (%s %s): %v", c.Request.Method, c.Request.URL.Path, err))
174 }
175 c.JSON(status, gin.H{"success": false, "code": code, "message": http.StatusText(status)})
176}
177
178func setAuthNoStore(c *gin.Context) {
179 c.Header("Cache-Control", "no-store")

Callers 7

RefreshAuthFunction · 0.85
AuthLogoutFunction · 0.85
GetLoginSessionsFunction · 0.85
DeleteLoginSessionFunction · 0.85
RevokeOtherLoginSessionsFunction · 0.85
setupLoginAtAuthVersionFunction · 0.85

Calls 2

AuthSessionErrorCodeFunction · 0.92
LogErrorFunction · 0.92