diff --git a/src/internet/seafileservice.cpp b/src/internet/seafileservice.cpp index bd1eaf94b..6fb769da6 100644 --- a/src/internet/seafileservice.cpp +++ b/src/internet/seafileservice.cpp @@ -53,20 +53,9 @@ SeafileService::SeafileService(Application* app, InternetModel* parent) } bool SeafileService::has_credentials() const { - return !access_token().isEmpty(); -} - -bool SeafileService::is_authenticated() const { return !access_token_.isEmpty(); } -QString SeafileService::access_token() const { - QSettings s; - s.beginGroup(kSettingsGroup); - - return s.value("access_token").toString(); -} - void SeafileService::AddAuthorizationHeader(QNetworkRequest* request) const { request->setRawHeader("Authorization", QString("Token %1").arg(access_token_).toAscii()); @@ -177,7 +166,7 @@ void SeafileService::ChangeLibrary(const QString& new_library) { } void SeafileService::Connect() { - if (is_authenticated()) { + if (has_credentials()) { UpdateLibraries(); } else { ShowSettingsDialog(); diff --git a/src/internet/seafileservice.h b/src/internet/seafileservice.h index c2792a686..3cad45d10 100644 --- a/src/internet/seafileservice.h +++ b/src/internet/seafileservice.h @@ -48,7 +48,7 @@ class SeafileService : public CloudFileService { static const char* kServiceName; static const char* kSettingsGroup; - virtual bool has_credentials() const; + bool has_credentials() const; QUrl GetStreamingUrlFromSongId(const QString& library, const QString& filepath); // Get the token for an user (simple rest api) @@ -100,9 +100,6 @@ signals: const QString& mime_type); private: - QString access_token() const; - bool is_authenticated() const; - void AddAuthorizationHeader(QNetworkRequest* request) const; void UpdateLibraries(); diff --git a/src/internet/seafilesettingspage.cpp b/src/internet/seafilesettingspage.cpp index fb4bd3508..e146a1726 100644 --- a/src/internet/seafilesettingspage.cpp +++ b/src/internet/seafilesettingspage.cpp @@ -108,7 +108,9 @@ void SeafileSettingsPage::Save() { s.setValue("library", id); // Don't need to save the password - service_->ChangeLibrary(id); + if (service_->has_credentials()) { + service_->ChangeLibrary(id); + } } void SeafileSettingsPage::Login() {