mirror of
https://github.com/nextcloud/desktop.git
synced 2024-11-27 09:30:13 +03:00
Fail the sync if we close the browser without passing proper credentials.
This commit is contained in:
parent
c24d6bd71c
commit
704ba791fd
2 changed files with 25 additions and 4 deletions
|
@ -56,7 +56,7 @@ int shibboleth_redirect_callback(CSYNC* csync_ctx,
|
|||
// blocks
|
||||
refresher.refresh();
|
||||
|
||||
return 0;
|
||||
return creds->ready() ? 0 : 1;
|
||||
}
|
||||
|
||||
} // ns
|
||||
|
@ -100,7 +100,9 @@ QByteArray ShibbolethCredentials::prepareCookieData() const
|
|||
uniqueCookies.insert(cookieName, c.value());
|
||||
}
|
||||
|
||||
uniqueCookies.insert(_shibCookie.name(), _shibCookie.value());
|
||||
if (!_shibCookie.name().isEmpty()) {
|
||||
uniqueCookies.insert(_shibCookie.name(), _shibCookie.value());
|
||||
}
|
||||
foreach(const QString& cookieName, uniqueCookies.keys()) {
|
||||
cookiesAsString += cookieName;
|
||||
cookiesAsString += '=';
|
||||
|
@ -166,6 +168,8 @@ void ShibbolethCredentials::fetch()
|
|||
_browser = new ShibbolethWebView(QUrl(cfg.ownCloudUrl()));
|
||||
connect(_browser, SIGNAL(shibbolethCookieReceived(QNetworkCookie)),
|
||||
this, SLOT(onShibbolethCookieReceived(QNetworkCookie)));
|
||||
connect(_browser, SIGNAL(viewHidden()),
|
||||
this, SLOT(slotBrowserHidden()));
|
||||
_browser->show ();
|
||||
}
|
||||
}
|
||||
|
@ -175,19 +179,34 @@ void ShibbolethCredentials::persistForUrl(const QString& /*url*/)
|
|||
// nothing to do here, we don't store session cookies.
|
||||
}
|
||||
|
||||
void ShibbolethCredentials::onShibbolethCookieReceived(const QNetworkCookie& cookie)
|
||||
void ShibbolethCredentials::disposeBrowser()
|
||||
{
|
||||
_browser->hide();
|
||||
disconnect(_browser, SIGNAL(viewHidden()),
|
||||
this, SLOT(slotBrowserHidden()));
|
||||
disconnect(_browser, SIGNAL(shibbolethCookieReceived(QNetworkCookie)),
|
||||
this, SLOT(onShibbolethCookieReceived(QNetworkCookie)));
|
||||
_browser->hide();
|
||||
_browser->deleteLater();
|
||||
_browser = 0;
|
||||
}
|
||||
|
||||
void ShibbolethCredentials::onShibbolethCookieReceived(const QNetworkCookie& cookie)
|
||||
{
|
||||
disposeBrowser();
|
||||
_ready = true;
|
||||
_shibCookie = cookie;
|
||||
Q_EMIT newCookie(_shibCookie);
|
||||
Q_EMIT fetched();
|
||||
}
|
||||
|
||||
void ShibbolethCredentials::slotBrowserHidden()
|
||||
{
|
||||
disposeBrowser();
|
||||
_ready = false;
|
||||
_shibCookie = QNetworkCookie();
|
||||
Q_EMIT fetched();
|
||||
}
|
||||
|
||||
void ShibbolethCredentials::invalidateAndFetch()
|
||||
{
|
||||
_ready = false;
|
||||
|
|
|
@ -47,6 +47,7 @@ public Q_SLOTS:
|
|||
|
||||
private Q_SLOTS:
|
||||
void onShibbolethCookieReceived(const QNetworkCookie& cookie);
|
||||
void slotBrowserHidden();
|
||||
void onFetched();
|
||||
|
||||
Q_SIGNALS:
|
||||
|
@ -55,6 +56,7 @@ Q_SIGNALS:
|
|||
|
||||
private:
|
||||
QByteArray prepareCookieData() const;
|
||||
void disposeBrowser();
|
||||
|
||||
QNetworkCookie _shibCookie;
|
||||
bool _ready;
|
||||
|
|
Loading…
Reference in a new issue