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:esteem.app</string>
<string>webcredentials:esteem.app</string>
<string>applinks:steem</string>
</array>
</dict>
</plist>

View File

@ -146,8 +146,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) => {
let userData = {

View File

@ -151,23 +151,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",
},
},
],
},
},
});
};

View File

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

View File

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