Add access token and wallet address to GitHub reward

This commit is contained in:
Alex Liebowitz 2017-03-30 00:48:18 -04:00 committed by Jeremy Kauffman
parent 6cc2892399
commit c374a59af8
2 changed files with 21 additions and 22 deletions

View file

@ -28,18 +28,13 @@ const mocks = {
}; };
lbryio.call = function(resource, action, params, method='get') { lbryio.call = function(resource, action, params, method='get') {
console.log('top of lbryio.call')
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
console.log('top of promise handler')
/* temp code for mocks */ /* temp code for mocks */
if (`${resource}.${action}` in mocks) { if (`${resource}.${action}` in mocks) {
console.log(`found ${resource}.${action} in mocks`)
resolve(mocks[`${resource}.${action}`](params)); resolve(mocks[`${resource}.${action}`](params));
console.log('...resolved.');
return; return;
} else {
console.log(`did not find ${resource}.${action} in mocks`);
} }
/* end temp */ /* end temp */
console.log('about to create xhr object'); console.log('about to create xhr object');

View file

@ -13,34 +13,38 @@ const LinkGithubReward = React.createClass({
onClaimed: React.PropTypes.func, onClaimed: React.PropTypes.func,
}, },
_launchLinkPage: function() { _launchLinkPage: function() {
const githubAuthParams = { /* const githubAuthParams = {
client_id: GITHUB_CLIENT_ID, client_id: GITHUB_CLIENT_ID,
redirect_uri: 'https://lbry.io/', redirect_uri: 'https://lbry.io/',
scope: 'user:email,public_repo', scope: 'user:email,public_repo',
allow_signup: false, allow_signup: false,
} }
shell.openExternal('https://github.com/login/oauth/authorize?' + querystring.stringify(githubAuthParams)); shell.openExternal('https://github.com/login/oauth/authorize?' + querystring.stringify(githubAuthParams)); */
shell.openExternal('https://lbry.io');
}, },
handleConfirmClicked: function() { handleConfirmClicked: function() {
this.setState({ this.setState({
confirming: true, confirming: true,
}); });
lbryio.call('reward', 'new', { lbry.get_new_address().then((address) => {
reward_type: 'new_developer', lbryio.call('reward', 'new', {
access_token: 'token will go here', reward_type: 'new_developer',
}, 'post').then((response) => { access_token: '**access token here**',
console.log('response:', response); wallet_address: address,
}, 'post').then((response) => {
console.log('response:', response);
this.props.onClaimed(); // This will trigger another API call to show that we succeeded this.props.onClaimed(); // This will trigger another API call to show that we succeeded
this.setState({ this.setState({
confirming: false, confirming: false,
}); });
}, (error) => { }, (error) => {
console.log('failed with error:', error); console.log('failed with error:', error);
this.setState({ this.setState({
confirming: false, confirming: false,
});
}); });
}); });
}, },
@ -54,7 +58,7 @@ const LinkGithubReward = React.createClass({
<section> <section>
<section className="reward-page__details"> <section className="reward-page__details">
<p><Link button="alt" label="Link with GitHub" onClick={this._launchLinkPage} /></p> <p><Link button="alt" label="Link with GitHub" onClick={this._launchLinkPage} /></p>
<p>This will open browser window where you can authorize GitHub to link your account to LBRY. This will record your email (no spam) and star the LBRY repo.</p> <p>This will open a browser window where you can authorize GitHub to link your account to LBRY. This will record your email (no spam) and star the LBRY repo.</p>
<p>Once you're finished, you may confirm you've linked the account to receive your reward.</p> <p>Once you're finished, you may confirm you've linked the account to receive your reward.</p>
</section> </section>