mirror of
https://github.com/ecency/ecency-mobile.git
synced 2024-12-23 13:22:02 +03:00
Merged with master
This commit is contained in:
commit
d375f6ca80
@ -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>
|
||||||
|
@ -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 = {
|
||||||
|
@ -151,10 +151,7 @@ class LoginPage extends Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
loginwithSc2 = () => {
|
loginwithSc2 = () => {
|
||||||
Navigation.showModal({
|
Navigation.push(this.props.componentId, {
|
||||||
stack: {
|
|
||||||
children: [
|
|
||||||
{
|
|
||||||
component: {
|
component: {
|
||||||
name: "navigation.eSteem.SteemConnect",
|
name: "navigation.eSteem.SteemConnect",
|
||||||
passProps: {},
|
passProps: {},
|
||||||
@ -166,9 +163,6 @@ class LoginPage extends Component {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -11,13 +11,18 @@ 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();
|
goToAuthScreens();
|
||||||
|
} else {
|
||||||
|
goToNoAuthScreens();
|
||||||
}
|
}
|
||||||
|
})
|
||||||
|
.catch(error => {
|
||||||
|
console.log(error);
|
||||||
|
goToAuthScreens();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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",
|
||||||
};
|
};
|
||||||
|
@ -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,16 +13,30 @@ export default class SteemConnect extends Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
onNavigationStateChange(event) {
|
onNavigationStateChange(event) {
|
||||||
let access_token = event.url.match(
|
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]*?)\&/
|
/\?(?:access_token)\=([\S\s]*?)\&/
|
||||||
)[1];
|
)[1];
|
||||||
if (access_token) {
|
} catch (error) {
|
||||||
loginWithSC2(access_token, "pinCode").then(result => {
|
console.log(error);
|
||||||
|
}
|
||||||
|
|
||||||
|
loginWithSC2(access_token, "pinCode")
|
||||||
|
.then(result => {
|
||||||
if (result === true) {
|
if (result === true) {
|
||||||
// TODO: Handle pinCode and navigate to home page
|
// TODO: Handle pinCode and navigate to home page
|
||||||
|
goToAuthScreens();
|
||||||
} else {
|
} else {
|
||||||
Navigation.dismissModal(this.props.componentId);
|
// 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>
|
||||||
|
Loading…
Reference in New Issue
Block a user