Sign up via GitHub #142

Merged
raucao merged 14 commits from feature/signup into master 2019-08-29 10:52:04 +00:00
9 changed files with 99 additions and 36 deletions
Showing only changes of commit 413bcddb1e - Show all commits
+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;
}
}
});
+1
View File
@@ -27,6 +27,7 @@ Router.map(function() {
this.route('edit', { path: ':id/edit' });
});
this.route('signup', function() {
this.route('github');
this.route('eth-account');
});
});
+13
View File
@@ -1,4 +1,17 @@
import Route from '@ember/routing/route';
import { inject as service } from '@ember/service';
import { isEmpty } from '@ember/utils';
export default Route.extend({
kredits: service(),
redirect () {
this._super(...arguments);
if (isEmpty(this.kredits.githubAccessToken)) {
this.transitionTo('signup.index');
}
}
});
+18
View File
@@ -0,0 +1,18 @@
import Route from '@ember/routing/route';
import { inject as service } from '@ember/service';
export default Route.extend({
kredits: service(),
redirect () {
this._super(...arguments);
const accessToken = window.location.hash.match(/access_token=(.+)/)[1];
this.kredits.set('githubAccessToken', accessToken);
this.transitionTo('signup.eth-account');
}
});
+1
View File
@@ -24,6 +24,7 @@ export default Service.extend({
contributors: null,
contributions: null,
proposals: null,
githubAccessToken: null,
currentUserIsContributor: notEmpty('currentUser'),
currentUserIsCore: alias('currentUser.isCore'),
+2 -2
View File
@@ -8,8 +8,8 @@
connecting one of the following accounts:
</p>
<p class="actions">
{{#link-to "signup.eth-account" class="button icon"}}
<button {{action "connectGithub"}} class="icon">
{{icon-account-github-com}}
Connect GitHub
{{/link-to}}
</button>
</p>
+6
View File
@@ -37,6 +37,9 @@ module.exports = function(environment) {
raucao commented 2019-07-26 10:42:12 +00:00 (Migrated from github.com)
Review

Why is this using a port number? This should actually fail, as the HTTPS nginx sites are not listening on those ports.

https://gitea.kosmos.org/kosmos/chef/src/branch/master/site-cookbooks/kosmos-hubot/templates/default/nginx_conf_hubot.erb#L10

Why is this using a port number? This should actually fail, as the HTTPS nginx sites are not listening on those ports. https://gitea.kosmos.org/kosmos/chef/src/branch/master/site-cookbooks/kosmos-hubot/templates/default/nginx_conf_hubot.erb#L10
galfert commented 2019-07-26 17:04:27 +00:00 (Migrated from github.com)
Review

Oh, yes. I didn't know the actual URL, so I searched the chef repo and found this: https://gitea.kosmos.org/kosmos/chef/src/branch/master/site-cookbooks/kosmos-hubot/attributes/default.rb#L6-L7

It's fixed now.

Oh, yes. I didn't know the actual URL, so I searched the chef repo and found this: https://gitea.kosmos.org/kosmos/chef/src/branch/master/site-cookbooks/kosmos-hubot/attributes/default.rb#L6-L7 It's fixed now.
web3ProviderUrl: 'https://rinkeby.infura.io/v3/d4f788b7a6584f7db2fc3c268d4d09e9',
githubConnectUrl: 'https://hal8000.chat.kosmos.org:8082/kredits/signup/connect/github',
githubSignupUrl: 'https://hal8000.chat.kosmos.org:8082/kredits/signup/github',
ipfs: {
host: 'ipfs.kosmos.org',
port: '5444',
@@ -53,6 +56,9 @@ module.exports = function(environment) {
// ENV.APP.LOG_VIEW_LOOKUPS = true;
ENV.web3ProviderUrl = 'https://rinkeby.infura.io/v3/d4f788b7a6584f7db2fc3c268d4d09e9';
ENV.githubConnectUrl = 'http://localhost:8888/kredits/signup/connect/github';
ENV.githubSignupUrl = 'http://localhost:8888/kredits/signup/github';
ENV.ipfs = {
host: 'localhost',
port: '5001',
+13 -32
View File
@@ -9429,8 +9429,7 @@
"ansi-regex": {
"version": "2.1.1",
"bundled": true,
"dev": true,
"optional": true
"dev": true
},
"aproba": {
"version": "1.2.0",
@@ -9451,14 +9450,12 @@
"balanced-match": {
"version": "1.0.0",
"bundled": true,
"dev": true,
"optional": true
"dev": true
},
"brace-expansion": {
"version": "1.1.11",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"balanced-match": "^1.0.0",
"concat-map": "0.0.1"
@@ -9473,20 +9470,17 @@
"code-point-at": {
"version": "1.1.0",
"bundled": true,
"dev": true,
"optional": true
"dev": true
},
"concat-map": {
"version": "0.0.1",
"bundled": true,
"dev": true,
"optional": true
"dev": true
},
"console-control-strings": {
"version": "1.1.0",
"bundled": true,
"dev": true,
"optional": true
"dev": true
},
"core-util-is": {
"version": "1.0.2",
@@ -9603,8 +9597,7 @@
"inherits": {
"version": "2.0.3",
"bundled": true,
"dev": true,
"optional": true
"dev": true
},
"ini": {
"version": "1.3.5",
@@ -9616,7 +9609,6 @@
"version": "1.0.0",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"number-is-nan": "^1.0.0"
}
@@ -9631,7 +9623,6 @@
"version": "3.0.4",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"brace-expansion": "^1.1.7"
}
@@ -9639,14 +9630,12 @@
"minimist": {
"version": "0.0.8",
"bundled": true,
"dev": true,
"optional": true
"dev": true
},
"minipass": {
"version": "2.3.5",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"safe-buffer": "^5.1.2",
"yallist": "^3.0.0"
@@ -9665,7 +9654,6 @@
"version": "0.5.1",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"minimist": "0.0.8"
}
@@ -9746,8 +9734,7 @@
"number-is-nan": {
"version": "1.0.1",
"bundled": true,
"dev": true,
"optional": true
"dev": true
},
"object-assign": {
"version": "4.1.1",
@@ -9759,7 +9746,6 @@
"version": "1.4.0",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"wrappy": "1"
}
@@ -9845,8 +9831,7 @@
"safe-buffer": {
"version": "5.1.2",
"bundled": true,
"dev": true,
"optional": true
"dev": true
},
"safer-buffer": {
"version": "2.1.2",
@@ -9882,7 +9867,6 @@
"version": "1.0.2",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"code-point-at": "^1.0.0",
"is-fullwidth-code-point": "^1.0.0",
@@ -9902,7 +9886,6 @@
"version": "3.0.1",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"ansi-regex": "^2.0.0"
}
@@ -9946,14 +9929,12 @@
"wrappy": {
"version": "1.0.2",
"bundled": true,
"dev": true,
"optional": true
"dev": true
},
"yallist": {
"version": "3.0.3",
"bundled": true,
"dev": true,
"optional": true
"dev": true
}
}
},
@@ -10883,7 +10864,7 @@
"bs58": "^4.0.1",
"buffer": "^5.2.1",
"cids": "~0.5.5",
"concat-stream": "github:hugomrdias/concat-stream#feat/smaller",
"concat-stream": "github:hugomrdias/concat-stream#057bc7b5d6d8df26c8cf00a3f151b6721a0a8034",
"debug": "^4.1.0",
"detect-node": "^2.0.4",
"end-of-stream": "^1.4.1",
@@ -10905,7 +10886,7 @@
"multibase": "~0.6.0",
"multicodec": "~0.5.0",
"multihashes": "~0.4.14",
"ndjson": "github:hugomrdias/ndjson#feat/readable-stream3",
"ndjson": "github:hugomrdias/ndjson#4db16da6b42e5b39bf300c3a7cde62abb3fa3a11",
"once": "^1.4.0",
"peer-id": "~0.12.2",
"peer-info": "~0.15.1",