allow anyone with lbc into early access
This commit is contained in:
parent
e73f367045
commit
a8d85d7c1d
10 changed files with 127 additions and 70 deletions
|
@ -107,7 +107,6 @@ function launchDaemon() {
|
|||
daemonSubprocess.stdout.on('data', (buf) => {console.log(String(buf).trim());});
|
||||
daemonSubprocess.stderr.on('data', (buf) => {console.log(String(buf).trim());});
|
||||
daemonSubprocess.on('exit', handleDaemonSubprocessExited);
|
||||
console.log('lbrynet daemon has launched')
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -1,4 +0,0 @@
|
|||
#!/bin/bash
|
||||
rm -rf ~/.lbrynet/
|
||||
rm -rf ~/.lbryum/
|
||||
./node_modules/.bin/electron app
|
|
@ -1,12 +1,11 @@
|
|||
import React from 'react';
|
||||
import lbryio from '../lbryio.js';
|
||||
|
||||
import Modal from './modal.js';
|
||||
import ModalPage from './modal-page.js';
|
||||
import {Link, RewardLink} from '../component/link.js';
|
||||
import {FormField, FormRow} from '../component/form.js';
|
||||
import {CreditAmount} from '../component/common.js';
|
||||
import rewards from '../rewards.js';
|
||||
import React from "react";
|
||||
import lbryio from "../lbryio.js";
|
||||
import Modal from "./modal.js";
|
||||
import ModalPage from "./modal-page.js";
|
||||
import {Link, RewardLink} from "../component/link.js";
|
||||
import {FormRow} from "../component/form.js";
|
||||
import {CreditAmount, Address} from "../component/common.js";
|
||||
import {getLocal, getSession, setSession, setLocal} from '../utils.js';
|
||||
|
||||
|
||||
const SubmitEmailStage = React.createClass({
|
||||
|
@ -22,6 +21,9 @@ const SubmitEmailStage = React.createClass({
|
|||
email: event.target.value,
|
||||
});
|
||||
},
|
||||
onEmailSaved: function(email) {
|
||||
this.props.setStage("confirm", { email: email })
|
||||
},
|
||||
handleSubmit: function(event) {
|
||||
event.preventDefault();
|
||||
|
||||
|
@ -29,10 +31,10 @@ const SubmitEmailStage = React.createClass({
|
|||
submitting: true,
|
||||
});
|
||||
lbryio.call('user_email', 'new', {email: this.state.email}, 'post').then(() => {
|
||||
this.props.onEmailSaved(this.state.email);
|
||||
this.onEmailSaved(this.state.email);
|
||||
}, (error) => {
|
||||
if (error.xhr && error.xhr.status == 409) {
|
||||
this.props.onEmailSaved(this.state.email);
|
||||
this.onEmailSaved(this.state.email);
|
||||
return;
|
||||
} else if (this._emailRow) {
|
||||
this._emailRow.showError(error.message)
|
||||
|
@ -85,7 +87,7 @@ const ConfirmEmailStage = React.createClass({
|
|||
|
||||
lbryio.call('user_email', 'confirm', {verification_token: this.state.code, email: this.props.email}, 'post').then((userEmail) => {
|
||||
if (userEmail.IsVerified) {
|
||||
this.props.onEmailConfirmed();
|
||||
this.props.setStage("welcome")
|
||||
} else {
|
||||
onSubmitError(new Error("Your email is still not verified.")) //shouldn't happen?
|
||||
}
|
||||
|
@ -98,9 +100,12 @@ const ConfirmEmailStage = React.createClass({
|
|||
<FormRow label="Verification Code" ref={(ref) => { this._codeRow = ref }} type="text"
|
||||
name="code" placeholder="a94bXXXXXXXXXXXXXX" value={this.state.code} onChange={this.handleCodeChanged}
|
||||
helper="A verification code is required to access this version."/>
|
||||
<div className="form-row-submit">
|
||||
<div className="form-row-submit form-row-submit--with-footer">
|
||||
<Link button="primary" label="Verify" disabled={this.state.submitting} onClick={this.handleSubmit} />
|
||||
</div>
|
||||
<div className="form-field__helper">
|
||||
No code? <Link onClick={() => { this.props.setStage("nocode")}} label="Click here" />.
|
||||
</div>
|
||||
</form>
|
||||
</section>
|
||||
);
|
||||
|
@ -176,10 +181,66 @@ const PendingStage = React.createClass({
|
|||
}
|
||||
});
|
||||
|
||||
|
||||
const CodeRequiredStage = React.createClass({
|
||||
_balanceSubscribeId: null,
|
||||
getInitialState: function() {
|
||||
return {
|
||||
balance: 0,
|
||||
address: getLocal('wallet_address')
|
||||
}
|
||||
},
|
||||
|
||||
componentWillMount: function() {
|
||||
this._balanceSubscribeId = lbry.balanceSubscribe((balance) => {
|
||||
this.setState({
|
||||
balance: balance
|
||||
});
|
||||
})
|
||||
|
||||
if (!this.state.address) {
|
||||
lbry.call('wallet_new_address', {}, (address) => {
|
||||
setLocal('wallet_address', address);
|
||||
this.setState({ address: address });
|
||||
});
|
||||
}
|
||||
},
|
||||
componentWillUnmount: function() {
|
||||
if (this._balanceSubscribeId) {
|
||||
lbry.balanceUnsubscribe(this._balanceSubscribeId)
|
||||
}
|
||||
},
|
||||
render: function() {
|
||||
const disabled = this.state.balance < 1;
|
||||
return (
|
||||
<div>
|
||||
<section className="section-spaced">
|
||||
<p>Access to LBRY is restricted as we build and scale the network.</p>
|
||||
<p>There are two ways in:</p>
|
||||
<h3>Own LBRY Credits</h3>
|
||||
<p>If you own at least 1 LBC, you can get in right now.</p>
|
||||
<p style={{ textAlign: "center"}}><Link onClick={() => { setLocal('auth_bypassed', true); this.props.setStage(null); }}
|
||||
disabled={disabled} label="Let Me In" button={ disabled ? "alt" : "primary" } /></p>
|
||||
<p>Your balance is <CreditAmount amount={this.state.balance} />. To increase your balance, send credits to this address:</p>
|
||||
<p><Address address={ this.state.address ? this.state.address : "Generating Address..." } /></p>
|
||||
<p>If you don't understand how to send credits, then...</p>
|
||||
</section>
|
||||
<section>
|
||||
<h3>Wait For A Code</h3>
|
||||
<p>If you provide your email, you'll automatically receive a notification when the system is open.</p>
|
||||
<p><Link onClick={() => { this.props.setStage("email"); }} label="Return" /></p>
|
||||
</section>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
export const AuthOverlay = React.createClass({
|
||||
_stages: {
|
||||
pending: PendingStage,
|
||||
error: ErrorStage,
|
||||
nocode: CodeRequiredStage,
|
||||
email: SubmitEmailStage,
|
||||
confirm: ConfirmEmailStage,
|
||||
welcome: WelcomeStage
|
||||
|
@ -190,42 +251,31 @@ export const AuthOverlay = React.createClass({
|
|||
stageProps: {}
|
||||
};
|
||||
},
|
||||
endAuth: function() {
|
||||
setStage: function(stage, stageProps = {}) {
|
||||
this.setState({
|
||||
stage: null
|
||||
});
|
||||
stage: stage,
|
||||
stageProps: stageProps
|
||||
})
|
||||
},
|
||||
componentWillMount: function() {
|
||||
lbryio.authenticate().then(function(user) {
|
||||
if (!user.HasVerifiedEmail) { //oops I fucked this up
|
||||
this.setState({
|
||||
stage: "email",
|
||||
stageProps: {
|
||||
onEmailSaved: function(email) {
|
||||
this.setState({
|
||||
stage: "confirm",
|
||||
stageProps: {
|
||||
email: email,
|
||||
onEmailConfirmed: function() { this.setState({ stage: "welcome"}) }.bind(this)
|
||||
}
|
||||
})
|
||||
}.bind(this)
|
||||
}
|
||||
})
|
||||
lbryio.authenticate().then((user) => {
|
||||
if (!user.HasVerifiedEmail) {
|
||||
if (getLocal('auth_bypassed')) {
|
||||
this.setStage(null)
|
||||
} else {
|
||||
this.setStage("email", {})
|
||||
}
|
||||
} else {
|
||||
lbryio.call('reward', 'list', {}).then(function(userRewards) {
|
||||
lbryio.call('reward', 'list', {}).then((userRewards) => {
|
||||
userRewards.filter(function(reward) {
|
||||
return reward.RewardType == "new_user" && reward.TransactionID;
|
||||
}).length ?
|
||||
this.endAuth() :
|
||||
this.setState({ stage: "welcome" })
|
||||
}.bind(this));
|
||||
this.setStage(null) :
|
||||
this.setStage("welcome")
|
||||
});
|
||||
}
|
||||
}.bind(this)).catch((err) => {
|
||||
this.setState({
|
||||
stage: "error",
|
||||
stageProps: { errorText: err.message }
|
||||
})
|
||||
}).catch((err) => {
|
||||
this.setStage("error", { errorText: err.message })
|
||||
document.dispatchEvent(new CustomEvent('unhandledError', {
|
||||
detail: {
|
||||
message: err.message,
|
||||
|
@ -243,9 +293,9 @@ export const AuthOverlay = React.createClass({
|
|||
this.state.stage != "welcome" ?
|
||||
<ModalPage className="modal-page--full" isOpen={true} contentLabel="Authentication" {...this.props}>
|
||||
<h1>LBRY Early Access</h1>
|
||||
<StageContent {...this.state.stageProps} />
|
||||
<StageContent {...this.state.stageProps} setStage={this.setStage} />
|
||||
</ModalPage> :
|
||||
<StageContent endAuth={this.endAuth} {...this.state.stageProps} />
|
||||
<StageContent setStage={this.setStage} {...this.state.stageProps} />
|
||||
);
|
||||
}
|
||||
});
|
|
@ -149,12 +149,14 @@ var addressStyle = {
|
|||
fontFamily: '"Consolas", "Lucida Console", "Adobe Source Code Pro", monospace',
|
||||
};
|
||||
export let Address = React.createClass({
|
||||
_inputElem: null,
|
||||
propTypes: {
|
||||
address: React.PropTypes.string,
|
||||
},
|
||||
render: function() {
|
||||
return (
|
||||
<span style={addressStyle}>{this.props.address}</span>
|
||||
<input className="input-copyable" type="text" ref={(input) => { this._inputElem = input; }}
|
||||
onFocus={() => { this._inputElem.select(); }} style={addressStyle} readOnly="readonly" value={this.props.address}></input>
|
||||
);
|
||||
}
|
||||
});
|
||||
|
|
|
@ -7,10 +7,10 @@ const lbryio = {
|
|||
_accessToken: getLocal('accessToken'),
|
||||
_authenticationPromise: null,
|
||||
_user : null,
|
||||
enabled: false
|
||||
enabled: true
|
||||
};
|
||||
|
||||
const CONNECTION_STRING = 'https://api.lbry.io/';
|
||||
const CONNECTION_STRING = process.env.LBRY_APP_API_URL ? process.env.LBRY_APP_API_URL : 'https://api.lbry.io/';
|
||||
const EXCHANGE_RATE_TIMEOUT = 20 * 60 * 1000;
|
||||
|
||||
lbryio.getExchangeRates = function() {
|
||||
|
|
|
@ -38,20 +38,6 @@
|
|||
text-align: center;
|
||||
}
|
||||
|
||||
/*
|
||||
section
|
||||
{
|
||||
margin-bottom: $spacing-vertical;
|
||||
&:last-child
|
||||
{
|
||||
margin-bottom: 0;
|
||||
}
|
||||
&:only-child {
|
||||
margin-bottom: $spacing-vertical;
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
h2 {
|
||||
font-size: 1.75em;
|
||||
}
|
||||
|
@ -147,3 +133,7 @@ p
|
|||
font-size: 0.85em;
|
||||
color: $color-help;
|
||||
}
|
||||
|
||||
section.section-spaced {
|
||||
margin-bottom: $spacing-vertical;
|
||||
}
|
||||
|
|
|
@ -1,11 +1,16 @@
|
|||
@import "../global";
|
||||
|
||||
$width-input-border: 2px;
|
||||
$width-input-text: 330px;
|
||||
|
||||
.form-row-submit
|
||||
{
|
||||
margin-top: $spacing-vertical;
|
||||
}
|
||||
.form-row-submit--with-footer
|
||||
{
|
||||
margin-bottom: $spacing-vertical;
|
||||
}
|
||||
|
||||
.form-row__label-row {
|
||||
margin-top: $spacing-vertical * 5/6;
|
||||
|
@ -18,6 +23,18 @@ $width-input-border: 2px;
|
|||
margin-right: 5px;
|
||||
}
|
||||
|
||||
input[type="text"].input-copyable {
|
||||
border: 1px solid $color-form-border;
|
||||
line-height: 1;
|
||||
padding-top: $spacing-vertical * 1/3;
|
||||
padding-bottom: $spacing-vertical * 1/3;
|
||||
width: $width-input-text;
|
||||
padding-left: 5px;
|
||||
padding-right: 5px;
|
||||
width: 100%;
|
||||
&:focus { border-color: black; }
|
||||
}
|
||||
|
||||
.form-field {
|
||||
display: inline-block;
|
||||
|
||||
|
@ -66,7 +83,7 @@ $width-input-border: 2px;
|
|||
input[type="search"],
|
||||
input[type="date"] {
|
||||
border-bottom: $width-input-border solid $color-form-border;
|
||||
line-height: 1px;
|
||||
line-height: 1;
|
||||
padding-top: $spacing-vertical * 1/3;
|
||||
padding-bottom: $spacing-vertical * 1/3;
|
||||
&.form-field__input--error {
|
||||
|
@ -108,7 +125,7 @@ $width-input-border: 2px;
|
|||
}
|
||||
|
||||
.form-field__input-text {
|
||||
width: 330px;
|
||||
width: $width-input-text;
|
||||
}
|
||||
|
||||
.form-field__prefix {
|
||||
|
@ -124,7 +141,7 @@ $width-input-border: 2px;
|
|||
}
|
||||
|
||||
.form-field__input-textarea {
|
||||
width: 330px;
|
||||
width: $width-input-text;
|
||||
}
|
||||
|
||||
.form-field__error, .form-field__helper {
|
||||
|
|
|
@ -17,6 +17,9 @@
|
|||
right: 0;
|
||||
top: 0;
|
||||
bottom: 0;
|
||||
.modal-page__content {
|
||||
max-width: 500px;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -35,4 +35,4 @@ module.exports = {
|
|||
]
|
||||
},
|
||||
target: 'electron-main',
|
||||
};
|
||||
};
|
|
@ -38,4 +38,4 @@ module.exports = {
|
|||
]
|
||||
},
|
||||
target: 'electron-main',
|
||||
};
|
||||
};
|
Loading…
Reference in a new issue