-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #142 from 67P/feature/signup
Sign up via GitHub
- Loading branch information
Showing
28 changed files
with
595 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import Component from '@ember/component'; | ||
import { inject as service } from '@ember/service'; | ||
|
||
export default Component.extend({ | ||
|
||
tagName: '', | ||
|
||
kredits: service(), | ||
router: service(), | ||
|
||
actions: { | ||
|
||
signup() { | ||
this.router.transitionTo('signup'); | ||
} | ||
|
||
} | ||
|
||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<section id="user-account"> | ||
{{#if (and kredits.hasAccounts kredits.currentUser)}} | ||
{{kredits.currentUser.name}} | ||
{{#if kredits.currentUserIsCore}} | ||
<span class="core-flag">(core)</span> | ||
{{/if}} | ||
{{else}} | ||
Anonymous | ||
<button {{action "signup"}} class="small green">Sign up</button> | ||
{{/if}} | ||
</section> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import Controller from '@ember/controller'; | ||
import { computed } from '@ember/object'; | ||
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); | ||
}), | ||
|
||
signupButtonDisabled: not('isValidEthAccount'), | ||
|
||
actions: { | ||
|
||
completeSignup () { | ||
const payload = { | ||
accessToken: this.githubAccessToken, | ||
account: this.ethAddress | ||
} | ||
|
||
fetch(config.githubSignupUrl, { | ||
method: 'POST', | ||
headers: { 'Content-Type': 'application/json' }, | ||
body: JSON.stringify(payload) | ||
}) | ||
.then(res => res.json()) | ||
.then(data => { | ||
console.log('Created contributor:', data); | ||
|
||
this.setProperties({ | ||
githubAccessToken: null, | ||
ethAddress: null | ||
}); | ||
|
||
this.transitionToRoute('signup.complete'); | ||
}); | ||
} | ||
|
||
} | ||
|
||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} | ||
|
||
} | ||
|
||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import Route from '@ember/routing/route'; | ||
|
||
export default Route.extend({ | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import Route from '@ember/routing/route'; | ||
|
||
export default Route.extend({ | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +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'); | ||
} | ||
} | ||
|
||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
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); | ||
|
||
let accessToken; | ||
try { | ||
accessToken = window.location.hash.match(/access_token=(.+)/)[1]; | ||
} catch (error) { /* ignore */ } | ||
|
||
if (isEmpty(accessToken) || accessToken === 'undefined') { | ||
console.error('No GitHub access token found.'); | ||
this.transitionTo('signup'); | ||
return; | ||
} | ||
|
||
this.kredits.set('githubAccessToken', accessToken); | ||
|
||
this.transitionTo('signup.eth-account'); | ||
} | ||
|
||
}); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
header#topbar section#user-account { | ||
|
||
button { | ||
margin-left: 1.2rem; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,6 @@ | ||
<header id="topbar"> | ||
<h1>{{link-to "Kosmos Kredits" "dashboard"}}</h1> | ||
|
||
<section id="user-account"> | ||
{{#if kredits.hasAccounts }} | ||
{{#if kredits.currentUser}} | ||
{{kredits.currentUser.name}} | ||
{{#if kredits.currentUserIsCore}}(core){{/if}} | ||
{{/if}} | ||
{{else}} | ||
Anonymous | ||
{{/if}} | ||
</section> | ||
{{topbar-account-panel}} | ||
</header> | ||
|
||
{{outlet}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<main class="center-column"> | ||
<section id="signup"> | ||
{{outlet}} | ||
</section> | ||
</main> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<header> | ||
<h2>Welcome aboard!</h2> | ||
</header> | ||
<div class="content text-lg text-center"> | ||
<p> | ||
Congratulations. Your initial profile is now complete. | ||
</p> | ||
<p> | ||
Why not say hi to your fellow contributors | ||
<a href="https://wiki.kosmos.org/Main_Page#Community_.2F_Getting_in_touch_.2F_Getting_involved">in one of our chat rooms</a>?. | ||
</p> | ||
<p class="actions"> | ||
{{#link-to "dashboard" class="button small"}}Return to dashboard{{/link-to}} | ||
</p> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<header> | ||
<h2>Complete your contributor profile</h2> | ||
</header> | ||
<div class="content text-lg"> | ||
<p class="mg-bottom-md"> | ||
Kredits allow you to take part in project governance, and to earn rewards for | ||
your contributions. For both, you will need an Ethereum wallet/account. | ||
</p> | ||
<form {{action "submit" on="submit"}}> | ||
<p> | ||
<label> | ||
Ethereum account:<br> | ||
{{input type="text" value=ethAddress | ||
placeholder="0xF18E631Ea191aE4ebE70046Fcb01a436554421BA4" | ||
class=(if isValidEthAccount "valid" "")}} | ||
</label> | ||
</p> | ||
</form> | ||
<p class="actions"> | ||
<button disabled={{signupButtonDisabled}} | ||
{{action "completeSignup"}}> | ||
Complete my profile | ||
</button> | ||
</p> | ||
</div> |
Oops, something went wrong.