Wire up signup via Github

This commit is contained in:
2019-07-26 03:38:18 +02:00
parent c2273d1778
commit 413bcddb1e
9 changed files with 99 additions and 36 deletions
+31 -2
View File
@@ -1,11 +1,16 @@
import Controller from '@ember/controller';
import { computed } from '@ember/object';
import { not } from '@ember/object/computed';
import { alias, not } from '@ember/object/computed';
import { isAddress } from 'web3-utils';
import { inject as service } from '@ember/service';
import config from 'kredits-web/config/environment';
export default Controller.extend({
kredits: service(),
ethAddress: null,
githubAccessToken: alias('kredits.githubAccessToken'),
isValidEthAccount: computed('ethAddress', function() {
return isAddress(this.ethAddress);
@@ -15,7 +20,31 @@ export default Controller.extend({
actions: {
completeSignup() {
completeSignup () {
const payload = {
accessToken: this.githubAccessToken,
account: this.ethAddress
}
fetch(config.githubSignupUrl, {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify(payload)
}).then(response => {
return response.json();
})
.then(data => {
console.log('Created contributor:', data);
this.setProperties({
githubAccessToken: null,
ethAddress: null
});
// TODO show success message or transition to success page
});
}
}
+14
View File
@@ -0,0 +1,14 @@
import Controller from '@ember/controller';
import config from 'kredits-web/config/environment';
export default Controller.extend({
actions: {
connectGithub () {
window.location = config.githubConnectUrl;
}
}
});