Don't do seafile stuff unless signed in.
This commit is contained in:
parent
01ae151f8a
commit
0cd3d9b34f
@ -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();
|
||||
|
@ -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();
|
||||
|
@ -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() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user