oauth work around for 10.3.3 security features which resolves issue #11

This commit is contained in:
Morgan McMillian 2017-02-04 09:36:28 -08:00
parent e1a5c31adb
commit 0c8bc294c1
6 changed files with 53 additions and 1 deletions

View file

@ -1,5 +1,5 @@
1 1
45 46
AboutPage.qml AboutPage.qml
AppCover.qml AppCover.qml
LoginSheet.qml LoginSheet.qml
@ -45,3 +45,4 @@ icons/sign-out.png
icons/star-o.png icons/star-o.png
icons/star.png icons/star.png
StreamTab.qml StreamTab.qml
WebViewSheet.qml

View file

@ -212,6 +212,9 @@ NavigationPane {
pnut.sendPost(text) pnut.sendPost(text)
} }
}, },
WebViewSheet {
id: webViewSheet
},
QTimer { QTimer {
id: timer id: timer
interval: 30000 interval: 30000
@ -272,12 +275,19 @@ NavigationPane {
onAuthorizationReceived: { onAuthorizationReceived: {
console.log("-- THIS --") console.log("-- THIS --")
webViewSheet.close()
closeLogin() closeLogin()
pnut.getStream(endpoint, Pnut.STREAM_OLDER); pnut.getStream(endpoint, Pnut.STREAM_OLDER);
timer.start(); timer.start();
console.log("__Should be closed now") console.log("__Should be closed now")
} }
onOpenBrowser: {
//console.log("-- open browser --")
webViewSheet.url = url
webViewSheet.open()
}
onFollowSuccess: update_user_page(user) onFollowSuccess: update_user_page(user)
onUnfollowSuccess: update_user_page(user) onUnfollowSuccess: update_user_page(user)

26
assets/WebViewSheet.qml Normal file
View file

@ -0,0 +1,26 @@
import bb.cascades 1.4
Sheet {
peekEnabled: false
property alias url: webview.url
Page {
ScrollView {
scrollViewProperties.pinchToZoomEnabled: true
scrollViewProperties.scrollMode: ScrollMode.Both
WebView {
id: webview
settings.zoomToFitEnabled: true
onUrlChanged: {
//console.log("::" + url)
// Workaround for 10.3.3
if (url.toString().match(/http\:\/\/.*#access_token\=/i)) {
//console.log("Matched url: " + url.toString());
webview.stop();
webview.url = url.toString();
}
}
}
}
}
}

View file

@ -78,6 +78,7 @@ config_pri_assets {
$$quote($$BASEDIR/assets/ThreadPage.qml) \ $$quote($$BASEDIR/assets/ThreadPage.qml) \
$$quote($$BASEDIR/assets/UserItem.qml) \ $$quote($$BASEDIR/assets/UserItem.qml) \
$$quote($$BASEDIR/assets/UserPage.qml) \ $$quote($$BASEDIR/assets/UserPage.qml) \
$$quote($$BASEDIR/assets/WebViewSheet.qml) \
$$quote($$BASEDIR/assets/icons/at.png) \ $$quote($$BASEDIR/assets/icons/at.png) \
$$quote($$BASEDIR/assets/icons/bell-slash.png) \ $$quote($$BASEDIR/assets/icons/bell-slash.png) \
$$quote($$BASEDIR/assets/icons/bell.png) \ $$quote($$BASEDIR/assets/icons/bell.png) \

View file

@ -51,6 +51,11 @@ Pnut::Pnut()
Q_ASSERT(conn_req); Q_ASSERT(conn_req);
bool brw_req = connect(oauthManager, SIGNAL(openBrowser(QUrl)),
this, SLOT(onOpenBrowser(QUrl)));
Q_ASSERT(brw_req);
qDebug() << "Pnut created, I am life."; qDebug() << "Pnut created, I am life.";
} }
@ -519,3 +524,10 @@ void Pnut::getFollowing(QString uid)
req_map[++req_id] = ":following"; req_map[++req_id] = ":following";
getRequest(url, parameters, req_id); getRequest(url, parameters, req_id);
} }
void Pnut::onOpenBrowser(QUrl url)
{
qDebug() << "_onOpenBrowser_";
qDebug() << url;
emit openBrowser(url);
}

View file

@ -93,6 +93,7 @@ public slots:
void onRequestReady(QByteArray data); void onRequestReady(QByteArray data);
void onAuthorizedRequestReady(QByteArray data, int id); void onAuthorizedRequestReady(QByteArray data, int id);
void onAuthorizationReceived(QString token, QString verifier); void onAuthorizationReceived(QString token, QString verifier);
void onOpenBrowser(QUrl url);
Q_SIGNALS: Q_SIGNALS:
void authorizationRequired(); void authorizationRequired();
@ -108,6 +109,7 @@ Q_SIGNALS:
void postReceived(QVariantMap post); void postReceived(QVariantMap post);
void userStreamReceived(QVariantList stream); void userStreamReceived(QVariantList stream);
void userListReceived(QVariantList users); void userListReceived(QVariantList users);
void openBrowser(QUrl url);
private: private:
static const QString PNUT_API_ROOT; static const QString PNUT_API_ROOT;