Feat: emby logout

pull/48/head
zijiren233 2 years ago
parent a640e5bb40
commit 21204cacf0

@ -30,7 +30,7 @@ require (
github.com/sirupsen/logrus v1.9.3
github.com/soheilhy/cmux v0.1.5
github.com/spf13/cobra v1.8.0
github.com/synctv-org/vendors v0.2.2-0.20231226084816-6cd79508ca08
github.com/synctv-org/vendors v0.2.2-0.20231226121731-35912737bbb2
github.com/ulule/limiter/v3 v3.11.2
github.com/zencoder/go-dash/v3 v3.0.3
github.com/zijiren233/gencontainer v0.0.0-20231213075414-f7f4c8261dca

@ -350,8 +350,8 @@ github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o
github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
github.com/synctv-org/vendors v0.2.2-0.20231226084816-6cd79508ca08 h1:jJ1xn6EInG8u02YUKDioF36Y9ab9IC9eA0Z3lQ8o7FU=
github.com/synctv-org/vendors v0.2.2-0.20231226084816-6cd79508ca08/go.mod h1:Q+KEUh8ZgCSMjY5rCfz44+7POlHcGttZ/bYFiTDVBds=
github.com/synctv-org/vendors v0.2.2-0.20231226121731-35912737bbb2 h1:c9R7idpWvnqKvMxGkzQvJMoQ8os1shy+rgaawjk6xKw=
github.com/synctv-org/vendors v0.2.2-0.20231226121731-35912737bbb2/go.mod h1:Q+KEUh8ZgCSMjY5rCfz44+7POlHcGttZ/bYFiTDVBds=
github.com/tv42/httpunix v0.0.0-20150427012821-b75d8614f926/go.mod h1:9ESjWnEqriFuLhtthL60Sar/7RFoluCcXsuvEwTV5KM=
github.com/twitchyliquid64/golang-asm v0.15.1 h1:SU5vSMR7hnwNxj24w34ZyCi/FmDZTkS4MhqMhdFk5YI=
github.com/twitchyliquid64/golang-asm v0.15.1/go.mod h1:a1lVb/DtPvCB8fslRZhAngC2+aY1QWCk3Cedj/Gdt08=

@ -71,6 +71,10 @@ func (e *grpcEmby) Login(ctx context.Context, req *emby.LoginReq) (*emby.LoginRe
return e.client.Login(ctx, req)
}
func (e *grpcEmby) Logout(ctx context.Context, req *emby.LogoutReq) (*emby.Empty, error) {
return e.client.Logout(ctx, req)
}
func (e *grpcEmby) Me(ctx context.Context, req *emby.MeReq) (*emby.MeResp, error) {
return e.client.Me(ctx, req)
}

@ -107,7 +107,20 @@ func Logout(ctx *gin.Context) {
return
}
eucd := user.EmbyCache().Raw()
user.EmbyCache().Clear()
go logoutEmby(eucd)
ctx.Status(http.StatusNoContent)
}
func logoutEmby(eucd *cache.EmbyUserCacheData) {
if eucd == nil || eucd.ApiKey == "" {
return
}
_, _ = vendor.LoadEmbyClient(eucd.Backend).Logout(context.Background(), &emby.LogoutReq{
Host: eucd.Host,
Token: eucd.ApiKey,
})
}

Loading…
Cancel
Save