diff --git a/server/handlers/vendors/bilibili/me.go b/server/handlers/vendors/bilibili/me.go index 756c102f..19445e1f 100644 --- a/server/handlers/vendors/bilibili/me.go +++ b/server/handlers/vendors/bilibili/me.go @@ -25,13 +25,19 @@ func Me(ctx *gin.Context) { ctx.AbortWithStatusJSON(http.StatusInternalServerError, model.NewApiErrorResp(err)) return } + if len(vendor.Cookies) == 0 { + ctx.JSON(http.StatusOK, model.NewApiDataResp(&MeResp{ + IsLogin: false, + })) + return + } cli := bilibili.NewClient(vendor.Cookies) nav, err := cli.UserInfo() if err != nil { ctx.AbortWithStatusJSON(http.StatusInternalServerError, model.NewApiErrorResp(err)) return } - ctx.JSON(http.StatusOK, model.NewApiDataResp(MeResp{ + ctx.JSON(http.StatusOK, model.NewApiDataResp(&MeResp{ IsLogin: nav.Data.IsLogin, Username: nav.Data.Uname, Face: nav.Data.Face,