Add cookie convenience funcs

Fix test helper func
This commit is contained in:
y a t s
2026-06-18 11:44:25 -04:00
parent 72840af90e
commit 92438691f1
5 changed files with 49 additions and 37 deletions
+3 -5
View File
@@ -123,16 +123,14 @@ func (kf *KF) TwoFactorAuth(ctx context.Context, resp *http.Response, code uint3
}
func (kf *KF) IsLoggedIn() bool {
return getCookie(kf.client.Jar, kf.domain, "xf_user") != nil
return kf.Cookies.GetCookie(kf.domain, "xf_user") != nil
}
func (kf *KF) RefreshSession(ctx context.Context) (string, error) {
const COOKIE_NAME = "xf_session"
jar := kf.client.Jar
// Clear any existing session token to request a new one.
setCookie(jar, kf.domain, &http.Cookie{
kf.Cookies.SetCookie(kf.domain, &http.Cookie{
Name: COOKIE_NAME,
Value: "",
})
@@ -143,7 +141,7 @@ func (kf *KF) RefreshSession(ctx context.Context) (string, error) {
}
resp.Body.Close()
session := getCookie(jar, kf.domain, COOKIE_NAME)
session := kf.Cookies.GetCookie(kf.domain, COOKIE_NAME)
if session == nil {
return "", errors.New("Failed to get new xf_session cookie.")
}