Skip to content

Commit 6f4b233

Browse files
committed
chore: tweak log messages
1 parent 52925fd commit 6f4b233

File tree

3 files changed

+6
-7
lines changed

3 files changed

+6
-7
lines changed

leetcode/client.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ func (c *cnClient) send(req *http.Request, authType authType, result any, failur
177177
case withoutAuth:
178178
case withAuth:
179179
if err := c.opt.cred.AddCredentials(req); err != nil {
180-
log.Warn("add credentials failed", "err", err)
180+
log.Warn("add credentials failed, continue requesting without credentials", "err", err)
181181
}
182182
case requireAuth:
183183
if err := c.opt.cred.AddCredentials(req); err != nil {
@@ -546,7 +546,7 @@ func (c *cnClient) GetTodayQuestion() (*QuestionData, error) {
546546
graphqlRequest{
547547
query: query,
548548
operationName: "questionOfToday",
549-
authType: withAuth,
549+
authType: withoutAuth,
550550
}, &resp, nil,
551551
)
552552
if err != nil {
@@ -575,7 +575,7 @@ func (c *cnClient) GetQuestionOfDate(date time.Time) (*QuestionData, error) {
575575
"year": date.Year(),
576576
"month": int(date.Month()),
577577
},
578-
authType: withAuth,
578+
authType: withoutAuth,
579579
},
580580
&resp, nil,
581581
)

leetcode/client_us.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ func (c *usClient) GetTodayQuestion() (*QuestionData, error) {
134134
}`
135135
var resp gjson.Result
136136
_, err := c.graphqlPost(
137-
graphqlRequest{query: query, authType: withAuth}, &resp, nil,
137+
graphqlRequest{query: query, authType: withoutAuth}, &resp, nil,
138138
)
139139
if err != nil {
140140
return nil, err

leetcode/credential.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ func (p *passwordAuth) AddCredentials(req *http.Request) error {
108108
}
109109
}
110110
if !p.hasAuth() {
111-
return errors.New("no credential found")
111+
return errors.New("login failed")
112112
}
113113
}
114114
return p.cookiesAuth.AddCredentials(req)
@@ -143,7 +143,6 @@ func (b *browserAuth) AddCredentials(req *http.Request) error {
143143
if !b.hasAuth() {
144144
u, _ := url.Parse(b.c.BaseURI())
145145
domain := u.Host
146-
log.Info("reading cookies from browsers", "domain", domain)
147146

148147
defer func(start time.Time) {
149148
log.Debug("finished reading cookies", "elapsed", time.Since(start))
@@ -185,7 +184,7 @@ func (b *browserAuth) AddCredentials(req *http.Request) error {
185184
}
186185
b.LeetCodeSession = session
187186
b.CsrfToken = csrfToken
188-
log.Debug("found cookie", "browser", store.Browser())
187+
log.Info("found cookies", "browser", store.Browser(), "domain", domain)
189188
break
190189
}
191190
}

0 commit comments

Comments
 (0)