mirror of
https://gitgud.io/yats/libkiwi.git
synced 2026-06-27 22:45:21 -04:00
Add cookie convenience funcs
Fix test helper func
This commit is contained in:
@@ -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.")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user