Merged with master

This commit is contained in:
mistikk 2018-09-21 21:35:53 +03:00
commit d375f6ca80
6 changed files with 60 additions and 43 deletions

View File

@ -10,6 +10,7 @@
<string>applinks:busy.org</string> <string>applinks:busy.org</string>
<string>applinks:esteem.app</string> <string>applinks:esteem.app</string>
<string>webcredentials:esteem.app</string> <string>webcredentials:esteem.app</string>
<string>applinks:steem</string>
</array> </array>
</dict> </dict>
</plist> </plist>

View File

@ -146,8 +146,7 @@ export const loginWithSC2 = async (access_token, pinCode) => {
await steemConnect.setAccessToken(access_token); await steemConnect.setAccessToken(access_token);
account = await steemConnect.me(); account = await steemConnect.me();
console.log(account._id); //console.log(account.name);
console.log(account.name);
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
let userData = { let userData = {

View File

@ -151,23 +151,17 @@ class LoginPage extends Component {
} }
loginwithSc2 = () => { loginwithSc2 = () => {
Navigation.showModal({ Navigation.push(this.props.componentId, {
stack: { component: {
children: [ name: "navigation.eSteem.SteemConnect",
{ passProps: {},
component: { options: {
name: "navigation.eSteem.SteemConnect", topBar: {
passProps: {}, title: {
options: { text: "Login via SC2",
topBar: {
title: {
text: "Login via SC2",
},
},
},
}, },
}, },
], },
}, },
}); });
}; };

View File

@ -11,14 +11,19 @@ class SplashContainer extends React.Component {
super(props); super(props);
} }
async componentDidMount() { componentDidMount() {
await getAuthStatus().then(res => { getAuthStatus()
if (res) { .then(result => {
goToNoAuthScreens(); if (result === true) {
} else { goToAuthScreens();
} else {
goToNoAuthScreens();
}
})
.catch(error => {
console.log(error);
goToAuthScreens(); goToAuthScreens();
} });
});
} }
render() { render() {

View File

@ -1,7 +1,7 @@
export const steemConnectOptions = { export const steemConnectOptions = {
base_url: "https://steemconnect.com/oauth2/authorize", base_url: "https://steemconnect.com/oauth2/authorize",
client_id: "esteem-app", 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: scope:
"vote%2Ccomment%2Cdelete_comment%2Ccomment_options%2Ccustom_json%2Cclaim_reward_balance", "vote,comment,delete_comment,comment_options,custom_json,claim_reward_balance",
}; };

View File

@ -4,6 +4,7 @@ import { loginWithSC2 } from "../../providers/steem/auth";
import { steemConnectOptions } from "./config"; import { steemConnectOptions } from "./config";
import RNRestart from "react-native-restart"; import RNRestart from "react-native-restart";
import { Navigation } from "react-native-navigation"; import { Navigation } from "react-native-navigation";
import { goToAuthScreens } from "../../navigation";
export default class SteemConnect extends Component { export default class SteemConnect extends Component {
constructor(props) { constructor(props) {
@ -12,17 +13,31 @@ export default class SteemConnect extends Component {
} }
onNavigationStateChange(event) { onNavigationStateChange(event) {
let access_token = event.url.match( let access_token;
/\?(?:access_token)\=([\S\s]*?)\&/ console.log(event.url);
)[1]; if (event.url.indexOf("?access_token=") > -1) {
if (access_token) { this.webview.stopLoading();
loginWithSC2(access_token, "pinCode").then(result => { try {
if (result === true) { access_token = event.url.match(
// TODO: Handle pinCode and navigate to home page /\?(?:access_token)\=([\S\s]*?)\&/
} else { )[1];
Navigation.dismissModal(this.props.componentId); } 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);
});
} }
} }
@ -30,15 +45,18 @@ export default class SteemConnect extends Component {
return ( return (
<View style={{ flex: 1 }}> <View style={{ flex: 1 }}>
<WebView <WebView
onNavigationStateChange={state =>
this.onNavigationStateChange(state)
}
source={{ source={{
uri: `${steemConnectOptions.base_url}?client_id=${ uri: `${steemConnectOptions.base_url}?client_id=${
steemConnectOptions.client_id steemConnectOptions.client_id
}&redirect_uri=${steemConnectOptions.redirect_uri}&${ }&redirect_uri=${encodeURIComponent(
steemConnectOptions.scope steemConnectOptions.redirect_uri
}`, )}&${encodeURIComponent(steemConnectOptions.scope)}`,
}}
onNavigationStateChange={this.onNavigationStateChange.bind(
this
)}
ref={ref => {
this.webview = ref;
}} }}
/> />
</View> </View>