mirror of
https://github.com/ecency/ecency-mobile.git
synced 2024-12-28 07:55:08 +03:00
steemconnect fix
This commit is contained in:
parent
731b2ec138
commit
3d4e233e66
@ -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>
|
||||
|
@ -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",
|
||||
};
|
||||
|
@ -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 (
|
||||
<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}`
|
||||
}}/>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
render() {
|
||||
return (
|
||||
<View style={{ flex: 1 }}>
|
||||
<WebView
|
||||
source={{
|
||||
uri: `${steemConnectOptions.base_url}?client_id=${
|
||||
steemConnectOptions.client_id
|
||||
}&redirect_uri=${encodeURIComponent(
|
||||
steemConnectOptions.redirect_uri
|
||||
)}&${encodeURIComponent(steemConnectOptions.scope)}`,
|
||||
}}
|
||||
onNavigationStateChange={this.onNavigationStateChange.bind(
|
||||
this
|
||||
)}
|
||||
ref={ref => {
|
||||
this.webview = ref;
|
||||
}}
|
||||
/>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user