Changeset View
Changeset View
Standalone View
Standalone View
providers/ghprovider/ghresource.cpp
Show First 20 Lines • Show All 71 Lines • ▼ Show 20 Line(s) | |||||
72 | { | 72 | { | ||
73 | KIO::TransferJob *job = getTransferJob(QStringLiteral("/user/orgs"), token); | 73 | KIO::TransferJob *job = getTransferJob(QStringLiteral("/user/orgs"), token); | ||
74 | connect(job, &KIO::TransferJob::data, | 74 | connect(job, &KIO::TransferJob::data, | ||
75 | this, &Resource::slotOrgs); | 75 | this, &Resource::slotOrgs); | ||
76 | } | 76 | } | ||
77 | 77 | | |||
78 | void Resource::authenticate(const QString &name, const QString &password) | 78 | void Resource::authenticate(const QString &name, const QString &password) | ||
79 | { | 79 | { | ||
80 | auto job = createHttpAuthJob(QLatin1String("Authorization: Basic ") + QString::fromUtf8((name.toUtf8() + ':' + password.toUtf8()).toBase64())); | 80 | auto job = createHttpAuthJob(QLatin1String("Authorization: Basic ") + QString::fromUtf8(QByteArray(name.toUtf8() + ':' + password.toUtf8()).toBase64())); | ||
81 | job->addMetaData("PropagateHttpHeader","true"); | 81 | job->addMetaData("PropagateHttpHeader","true"); | ||
82 | connect(job, &KIO::StoredTransferJob::result, | 82 | connect(job, &KIO::StoredTransferJob::result, | ||
83 | this, &Resource::slotAuthenticate); | 83 | this, &Resource::slotAuthenticate); | ||
84 | job->start(); | 84 | job->start(); | ||
85 | } | 85 | } | ||
86 | 86 | | |||
87 | void Resource::twoFactorAuthenticate(const QString &transferHeader, const QString &code) | 87 | void Resource::twoFactorAuthenticate(const QString &transferHeader, const QString &code) | ||
88 | { | 88 | { | ||
89 | auto job = createHttpAuthJob(transferHeader + QLatin1String("\nX-GitHub-OTP: ") + code); | 89 | auto job = createHttpAuthJob(transferHeader + QLatin1String("\nX-GitHub-OTP: ") + code); | ||
90 | connect(job, &KIO::StoredTransferJob::result, | 90 | connect(job, &KIO::StoredTransferJob::result, | ||
91 | this, &Resource::slotAuthenticate); | 91 | this, &Resource::slotAuthenticate); | ||
92 | job->start(); | 92 | job->start(); | ||
93 | } | 93 | } | ||
94 | 94 | | |||
95 | void Resource::revokeAccess(const QString &id, const QString &name, const QString &password) | 95 | void Resource::revokeAccess(const QString &id, const QString &name, const QString &password) | ||
96 | { | 96 | { | ||
97 | QUrl url = baseUrl; | 97 | QUrl url = baseUrl; | ||
98 | url.setPath(url.path() + "/authorizations/" + id); | 98 | url.setPath(url.path() + "/authorizations/" + id); | ||
99 | KIO::TransferJob *job = KIO::http_delete(url, KIO::HideProgressInfo); | 99 | KIO::TransferJob *job = KIO::http_delete(url, KIO::HideProgressInfo); | ||
100 | job->addMetaData(QStringLiteral("customHTTPHeader"), "Authorization: Basic " + QString (name + ':' + password).toUtf8().toBase64()); | 100 | job->addMetaData(QStringLiteral("customHTTPHeader"), QLatin1String("Authorization: Basic ") + QString (name + ':' + password).toUtf8().toBase64()); | ||
101 | /* And we don't care if it's successful ;) */ | 101 | /* And we don't care if it's successful ;) */ | ||
102 | job->start(); | 102 | job->start(); | ||
103 | } | 103 | } | ||
104 | 104 | | |||
105 | KIO::TransferJob * Resource::getTransferJob(const QString &uri, const QString &token) const | 105 | KIO::TransferJob * Resource::getTransferJob(const QString &uri, const QString &token) const | ||
106 | { | 106 | { | ||
107 | QUrl url = baseUrl; | 107 | QUrl url = baseUrl; | ||
108 | url = url.adjusted(QUrl::StripTrailingSlash); | 108 | url = url.adjusted(QUrl::StripTrailingSlash); | ||
▲ Show 20 Lines • Show All 122 Lines • Show Last 20 Lines |