Fix IsLoggedIn() and some other error checking

This commit is contained in:
y a t s
2026-06-19 10:21:21 -04:00
parent 92438691f1
commit 74b923f06f
2 changed files with 11 additions and 3 deletions
+4 -3
View File
@@ -123,7 +123,8 @@ func (kf *KF) TwoFactorAuth(ctx context.Context, resp *http.Response, code uint3
}
func (kf *KF) IsLoggedIn() bool {
return kf.Cookies.GetCookie(kf.domain, "xf_user") != nil
cookie := kf.Cookies.GetCookie(kf.domain, "xf_user")
return !(cookie == nil || cookie.Value == "")
}
func (kf *KF) RefreshSession(ctx context.Context) (string, error) {
@@ -142,8 +143,8 @@ func (kf *KF) RefreshSession(ctx context.Context) (string, error) {
resp.Body.Close()
session := kf.Cookies.GetCookie(kf.domain, COOKIE_NAME)
if session == nil {
return "", errors.New("Failed to get new xf_session cookie.")
if session == nil || session.Value == "" {
return "", fmt.Errorf("Failed to get new %s cookie", COOKIE_NAME)
}
return session.Value, nil