处理无法播放的问题

处理无法播放的问题
This commit is contained in:
truewhile
2026-08-24 21:06:44 +08:00
parent 97d162569d
commit 43fdfe8202
19 changed files with 168 additions and 107 deletions
+8 -8
View File
@@ -42,14 +42,14 @@ func EmbyAuthRequired(secret string) gin.HandlerFunc {
return []byte(secret), nil
})
if err != nil || !parsed.Valid || claims.UserID == "" {
c.JSON(http.StatusUnauthorized, gin.H{
"Code": 40101,
"Message": "Invalid token",
})
c.Abort()
return
}
if err != nil || !parsed.Valid || claims.UserID == "" {
c.JSON(http.StatusUnauthorized, gin.H{
"Code": 40101,
"Message": "Invalid token",
})
c.Abort()
return
}
c.Set(EmbyCtxUserID, claims.UserID)
c.Set(CtxUserID, claims.UserID)
+6 -6
View File
@@ -106,13 +106,13 @@ func TestAuthRequiredSyncsAccessTokenCookieFromBearer(t *testing.T) {
},
})
router := gin.New()
router.Use(AuthRequired(secret))
router.GET("/api/test-auth-cookie", func(c *gin.Context) {
c.JSON(http.StatusOK, gin.H{"ok": true})
})
router := gin.New()
router.Use(AuthRequired(secret))
router.GET("/api/test-auth-cookie", func(c *gin.Context) {
c.JSON(http.StatusOK, gin.H{"ok": true})
})
req := httptest.NewRequest(http.MethodGet, "/api/test-auth-cookie", nil)
req := httptest.NewRequest(http.MethodGet, "/api/test-auth-cookie", nil)
req.Header.Set("Authorization", "Bearer "+token)
w := httptest.NewRecorder()
router.ServeHTTP(w, req)