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] 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) } }); }