From 89aa1759143a2ddc227aec416d8ae2daec0186c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=BCseyin=20TERK=C4=B0R?= Date: Sun, 16 Sep 2018 16:08:38 +0300 Subject: [PATCH 1/6] steemconnect options --- src/screens/steem-connect/config.js | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 src/screens/steem-connect/config.js diff --git a/src/screens/steem-connect/config.js b/src/screens/steem-connect/config.js new file mode 100644 index 000000000..35b43684e --- /dev/null +++ b/src/screens/steem-connect/config.js @@ -0,0 +1,6 @@ +export const steemConnectOptions = { + base_url: "https://steemconnect.com/oauth2/authorize", + client_id: "esteem-app", + redirect_uri: "http%3A%2F%2F127.0.0.1%3A3415%2F", // http://127.0.0.1:3415 + scope: "vote%2Ccomment%2Cdelete_comment%2Ccomment_options%2Ccustom_json%2Cclaim_reward_balance" +}; From c2920b1fadb7978f7399a84ba7da7ce8d02d13ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=BCseyin=20Terkir?= Date: Thu, 20 Sep 2018 15:48:00 +0300 Subject: [PATCH 2/6] steemConnect login bug fixes --- src/providers/steem/auth.js | 3 +-- src/screens/splash/splashContainer.js | 28 +++++++++++++++-------- src/screens/steem-connect/steemConnect.js | 11 +++++++-- 3 files changed, 29 insertions(+), 13 deletions(-) diff --git a/src/providers/steem/auth.js b/src/providers/steem/auth.js index 68259b1b6..b9beeab2d 100644 --- a/src/providers/steem/auth.js +++ b/src/providers/steem/auth.js @@ -179,8 +179,7 @@ export const loginWithSC2 = async (access_token, pinCode) => { await steemConnect.setAccessToken(access_token); account = await steemConnect.me(); - console.log(account._id); - console.log(account.name); + //console.log(account.name); return new Promise((resolve, reject) => { diff --git a/src/screens/splash/splashContainer.js b/src/screens/splash/splashContainer.js index 4ea59cbc3..46d2e0351 100644 --- a/src/screens/splash/splashContainer.js +++ b/src/screens/splash/splashContainer.js @@ -4,19 +4,29 @@ import { Text, View } from "react-native"; import { goToAuthScreens, goToNoAuthScreens } from "../../navigation"; import SplashScreen from "./splashScreen"; +import { getAuthStatus } from "../../realm/realm"; class SplashContainer extends React.Component { - constructor(props) { - super(props); - } + constructor(props) { + super(props); + } - componentDidMount() { - goToNoAuthScreens(); - } + componentDidMount() { + getAuthStatus().then(result => { + if(result === true) { + goToAuthScreens(); + } else { + goToNoAuthScreens(); + } + }).catch(error => { + console.log(error); + goToAuthScreens(); + }); + } - render() { - return ; - } + render() { + return ; + } } export default SplashContainer; diff --git a/src/screens/steem-connect/steemConnect.js b/src/screens/steem-connect/steemConnect.js index 3a6adb8e2..969181fd9 100644 --- a/src/screens/steem-connect/steemConnect.js +++ b/src/screens/steem-connect/steemConnect.js @@ -13,14 +13,21 @@ export default class SteemConnect extends Component { } onNavigationStateChange(event) { - let access_token = event.url.match(/\?(?:access_token)\=([\S\s]*?)\&/)[1]; + let access_token; + try { + access_token = event.url.match(/\?(?:access_token)\=([\S\s]*?)\&/)[1]; + } catch (error) { + console.log(error); + } if(access_token) { loginWithSC2(access_token, "pinCode").then(result => { if(result === true) { // TODO: Handle pinCode and navigate to home page - + Navigation.dismissModal(this.props.componentId); + RNRestart.Restart(); } else { Navigation.dismissModal(this.props.componentId); + // TODO: Error alert (Toast Message) } }); } From f0952009a2bc7f86cd998bf6a140766c9c2d3a91 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=BCseyin=20TERK=C4=B0R?= Date: Fri, 21 Sep 2018 12:26:38 +0300 Subject: [PATCH 3/6] steemconnect redirect issue --- src/screens/steem-connect/steemConnect.js | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/src/screens/steem-connect/steemConnect.js b/src/screens/steem-connect/steemConnect.js index 969181fd9..07c8a5094 100644 --- a/src/screens/steem-connect/steemConnect.js +++ b/src/screens/steem-connect/steemConnect.js @@ -14,21 +14,26 @@ export default class SteemConnect extends Component { onNavigationStateChange(event) { let access_token; - try { - access_token = event.url.match(/\?(?:access_token)\=([\S\s]*?)\&/)[1]; - } catch (error) { - console.log(error); - } - if(access_token) { + + if(event.url.startsWith("http://127.0.0.1:3415/?access_token=")) { + + try { + access_token = event.url.match(/\?(?:access_token)\=([\S\s]*?)\&/)[1]; + } catch (error) { + console.log(error); + } + loginWithSC2(access_token, "pinCode").then(result => { if(result === true) { // TODO: Handle pinCode and navigate to home page Navigation.dismissModal(this.props.componentId); - RNRestart.Restart(); + goToAuthScreens(); } else { Navigation.dismissModal(this.props.componentId); // TODO: Error alert (Toast Message) } + }).catch(error => { + console.log(error); }); } } From 632193acc6b408ec689dcd962285c78fc964577f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=BCseyin=20TERK=C4=B0R?= Date: Fri, 21 Sep 2018 12:52:19 +0300 Subject: [PATCH 4/6] Update steemConnect.js --- src/screens/steem-connect/steemConnect.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/screens/steem-connect/steemConnect.js b/src/screens/steem-connect/steemConnect.js index 07c8a5094..2605d2c7f 100644 --- a/src/screens/steem-connect/steemConnect.js +++ b/src/screens/steem-connect/steemConnect.js @@ -26,10 +26,8 @@ export default class SteemConnect extends Component { loginWithSC2(access_token, "pinCode").then(result => { if(result === true) { // TODO: Handle pinCode and navigate to home page - Navigation.dismissModal(this.props.componentId); goToAuthScreens(); } else { - Navigation.dismissModal(this.props.componentId); // TODO: Error alert (Toast Message) } }).catch(error => { From 731b2ec1388af302dc419205c91ed036eff408b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=BCseyin=20TERK=C4=B0R?= Date: Fri, 21 Sep 2018 12:53:46 +0300 Subject: [PATCH 5/6] Update login.js --- src/screens/login/login.js | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/src/screens/login/login.js b/src/screens/login/login.js index db91562dc..306e0bea4 100644 --- a/src/screens/login/login.js +++ b/src/screens/login/login.js @@ -117,21 +117,17 @@ class LoginPage extends Component { } loginwithSc2 = () => { - Navigation.showModal({ - stack: { - children: [{ - component: { - name: "navigation.eSteem.SteemConnect", - passProps: {}, - options: { - topBar: { - title: { - text: "Login via SC2" - } - } - } - } - }] + Navigation.push(this.props.componentId, { + component: { + name: "navigation.eSteem.SteemConnect", + passProps: {}, + options: { + topBar: { + title: { + text: "Login via SC2" + } + } + } } }); } From 3d4e233e66c9fca76e033b4f31e2c5dd89f2cbc1 Mon Sep 17 00:00:00 2001 From: Feruz Date: Fri, 21 Sep 2018 16:17:13 +0300 Subject: [PATCH 6/6] steemconnect fix --- ios/eSteem/eSteem.entitlements | 1 + src/screens/steem-connect/config.js | 6 +- src/screens/steem-connect/steemConnect.js | 91 +++++++++++++---------- 3 files changed, 57 insertions(+), 41 deletions(-) diff --git a/ios/eSteem/eSteem.entitlements b/ios/eSteem/eSteem.entitlements index 92287ce49..821f58d27 100644 --- a/ios/eSteem/eSteem.entitlements +++ b/ios/eSteem/eSteem.entitlements @@ -10,6 +10,7 @@ applinks:busy.org applinks:esteem.app webcredentials:esteem.app + applinks:steem diff --git a/src/screens/steem-connect/config.js b/src/screens/steem-connect/config.js index c9c849ce6..f615584df 100644 --- a/src/screens/steem-connect/config.js +++ b/src/screens/steem-connect/config.js @@ -1,7 +1,7 @@ export const steemConnectOptions = { base_url: "https://steemconnect.com/oauth2/authorize", client_id: "esteem-app", - redirect_uri: "http%3A%2F%2F127.0.0.1%3A3415%2F", // http://127.0.0.1:3415 + redirect_uri: "http://127.0.0.1:3415/", // http://127.0.0.1:3415 scope: - "vote%2Ccomment%2Cdelete_comment%2Ccomment_options%2Ccustom_json%2Cclaim_reward_balance", -}; \ No newline at end of file + "vote,comment,delete_comment,comment_options,custom_json,claim_reward_balance", +}; diff --git a/src/screens/steem-connect/steemConnect.js b/src/screens/steem-connect/steemConnect.js index 2605d2c7f..a34ece9c1 100644 --- a/src/screens/steem-connect/steemConnect.js +++ b/src/screens/steem-connect/steemConnect.js @@ -4,47 +4,62 @@ import { loginWithSC2 } from "../../providers/steem/auth"; import { steemConnectOptions } from "./config"; import RNRestart from "react-native-restart"; import { Navigation } from "react-native-navigation"; +import { goToAuthScreens } from "../../navigation"; export default class SteemConnect extends Component { - constructor(props) { - super(props); - this.state = { - }; - } - - onNavigationStateChange(event) { - let access_token; - - if(event.url.startsWith("http://127.0.0.1:3415/?access_token=")) { + constructor(props) { + super(props); + this.state = {}; + } - try { - access_token = event.url.match(/\?(?:access_token)\=([\S\s]*?)\&/)[1]; - } catch (error) { - console.log(error); - } + onNavigationStateChange(event) { + let access_token; + console.log(event.url); + if (event.url.indexOf("?access_token=") > -1) { + this.webview.stopLoading(); + try { + access_token = event.url.match( + /\?(?:access_token)\=([\S\s]*?)\&/ + )[1]; + } catch (error) { + console.log(error); + } - loginWithSC2(access_token, "pinCode").then(result => { - if(result === true) { - // TODO: Handle pinCode and navigate to home page - goToAuthScreens(); - } else { - // TODO: Error alert (Toast Message) - } - }).catch(error => { - console.log(error); - }); - } - } + loginWithSC2(access_token, "pinCode") + .then(result => { + if (result === true) { + // TODO: Handle pinCode and navigate to home page + goToAuthScreens(); + } else { + // TODO: Error alert (Toast Message) + console.log("loginWithSC2 error"); + } + }) + .catch(error => { + console.log(error); + }); + } + } - render() { - return ( - - this.onNavigationStateChange(state)} - source={{ - uri: `${steemConnectOptions.base_url}?client_id=${steemConnectOptions.client_id}&redirect_uri=${steemConnectOptions.redirect_uri}&${steemConnectOptions.scope}` - }}/> - - ); - } + render() { + return ( + + { + this.webview = ref; + }} + /> + + ); + } }