Only remove session cookies

This should disconnect without loosing long lived cookie
This commit is contained in:
Olivier Goffart 2014-05-28 15:24:14 +02:00
parent dd1152dd4f
commit ebe1f986f1
3 changed files with 6 additions and 5 deletions

View file

@ -215,7 +215,8 @@ void ShibbolethCredentials::persist(Account* account)
void ShibbolethCredentials::invalidateToken(Account *account)
{
CookieJar *jar = static_cast<CookieJar*>(account->networkAccessManager()->cookieJar());
jar->clearCookies();
jar->deleteCookie(_shibCookie);
jar->clearSessionCookies();
removeShibCookie(account);
_shibCookie = QNetworkCookie();
// ### access to ctx missing, but might not be required at all

View file

@ -106,9 +106,9 @@ bool CookieJar::deleteCookie(const QNetworkCookie &delCookie)
return removeSucceeded;
}
void CookieJar::clearCookies()
void CookieJar::clearSessionCookies()
{
setAllCookies(QList<QNetworkCookie>());
setAllCookies(removeExpired(allCookies()));
}
@ -139,7 +139,7 @@ QList<QNetworkCookie> CookieJar::removeExpired(const QList<QNetworkCookie> &cook
{
QList<QNetworkCookie> updatedList;
foreach(const QNetworkCookie &cookie, cookies) {
if (cookie.expirationDate() > QDateTime::currentDateTime()) {
if (cookie.expirationDate() > QDateTime::currentDateTime() && !cookie.isSessionCookie()) {
updatedList << cookie;
}
}

View file

@ -30,7 +30,7 @@ public:
QList<QNetworkCookie> cookiesForUrl(const QUrl &url) const;
virtual bool deleteCookie(const QNetworkCookie & cookie);
void clearCookies();
void clearSessionCookies();
signals:
void newCookiesForUrl(const QList<QNetworkCookie>& cookieList, const QUrl& url);