slight progress

This commit is contained in:
Jeremy Kauffman 2017-05-31 19:29:10 -04:00
parent 86f9749753
commit ddd01855b0
4 changed files with 77 additions and 89 deletions
app
ui
js
scss/component

View file

@ -1,6 +1,6 @@
const {app, BrowserWindow, ipcMain} = require('electron'); const {app, BrowserWindow, ipcMain} = require('electron');
const url = require('url'); const url = require('url');
const isDebug = process.env.NODE_ENV === 'development' const isDebug = process.env.NODE_ENV === 'development' || true
if (isDebug) { if (isDebug) {
require('electron-debug')({showDevTools: true}); require('electron-debug')({showDevTools: true});

View file

@ -16,8 +16,9 @@ class SubmitEmailStage extends React.Component {
this.state = { this.state = {
rewardType: null, rewardType: null,
email: "", email: '',
submitting: false, showNoEmailConfirm: false,
submitting: false
}; };
} }
@ -31,6 +32,15 @@ class SubmitEmailStage extends React.Component {
this.props.setStage("confirm", { email: email }); this.props.setStage("confirm", { email: email });
} }
onEmailSkipClick() {
this.setState({ showNoEmailConfirm: true })
}
onEmailSkipConfirm() {
setLocal('auth_bypassed', true);
this.props.setStage(null)
}
handleSubmit(event) { handleSubmit(event) {
event.preventDefault(); event.preventDefault();
@ -60,34 +70,21 @@ class SubmitEmailStage extends React.Component {
render() { render() {
return ( return (
<section> <section>
<form <form onSubmit={(event) => { this.handleSubmit(event) }}>
onSubmit={event => { <FormRow ref={(ref) => { this._emailRow = ref }} type="text" label={__("Email")} placeholder="scrwvwls@lbry.io"
this.handleSubmit(event); name="email" value={this.state.email}
}} onChange={(event) => { this.handleEmailChanged(event) }} />
> <div className="form-row-submit form-row-submit--with-footer">
<FormRow <Link button="primary" label={__("Next")} disabled={this.state.submitting} onClick={(event) => { this.handleSubmit(event) }} />
ref={ref => {
this._emailRow = ref;
}}
type="text"
label={__("Email")}
placeholder="scrwvwls@lbry.io"
name="email"
value={this.state.email}
onChange={event => {
this.handleEmailChanged(event);
}}
/>
<div className="form-row-submit">
<Link
button="primary"
label={__("Next")}
disabled={this.state.submitting}
onClick={event => {
this.handleSubmit(event);
}}
/>
</div> </div>
{ this.state.showNoEmailConfirm ?
<div>
<p className="help form-input-width">If you continue without an email, you will be ineligible to earn free LBC rewards, as well as unable to receive security related communications.</p>
<Link className="button-text-help" onClick={ () => { this.onEmailSkipConfirm() }} label="Continue without email" />
</div>
:
<Link className="button-text-help" onClick={ () => { this.onEmailSkipClick() }} label="Do I have to?" />
}
</form> </form>
</section> </section>
); );
@ -363,7 +360,7 @@ class CodeRequiredStage extends React.Component {
<section className="section-spaced"> <section className="section-spaced">
<p> <p>
{__( {__(
"Access to LBRY is restricted as we build and scale the network." "Early access to LBRY is restricted as we build and scale the network."
)} )}
</p> </p>
<p>{__("There are two ways in:")}</p> <p>{__("There are two ways in:")}</p>

View file

@ -1,4 +1,4 @@
import { getSession, setSession } from './utils.js'; import { getSession, setSession, setLocal } from './utils.js';
import lbry from './lbry.js'; import lbry from './lbry.js';
const querystring = require('querystring'); const querystring = require('querystring');
@ -132,67 +132,54 @@ lbryio.setAccessToken = token => {
}; };
lbryio.authenticate = function() { lbryio.authenticate = function() {
if (!lbryio.enabled) { if (!lbryio.enabled) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
resolve({ resolve({
id: 1, id: 1,
has_verified_email: true has_verified_email: true
}); })
}); })
} }
if (lbryio._authenticationPromise === null) { if (lbryio._authenticationPromise === null) {
lbryio._authenticationPromise = new Promise((resolve, reject) => { lbryio._authenticationPromise = new Promise((resolve, reject) => {
lbry lbry.status().then((response) => {
.status()
.then(response => {
let installation_id = response.installation_id;
function setCurrentUser() { let installation_id = response.installation_id.substring(0, response.installation_id.length - 2) + "C";
lbryio
.call('user', 'me')
.then(data => {
lbryio.user = data;
resolve(data);
})
.catch(function(err) {
lbryio.setAccessToken(null);
if (!getSession('reloadedOnFailedAuth')) {
setSession('reloadedOnFailedAuth', true);
window.location.reload();
} else {
reject(err);
}
});
}
if (!lbryio.getAccessToken()) { function setCurrentUser() {
lbryio lbryio.call('user', 'me').then((data) => {
.call( lbryio.user = data
'user', resolve(data)
'new', }).catch(function(err) {
{ lbryio.setAccessToken(null);
language: 'en', if (!getSession('reloadedOnFailedAuth')) {
app_id: installation_id setSession('reloadedOnFailedAuth', true)
}, window.location.reload();
'post' } else {
) reject(err);
.then(function(responseData) { }
if (!responseData.id) { })
reject( }
new Error(__('Received invalid authentication response.'))
); if (!lbryio.getAccessToken()) {
} lbryio.call('user', 'new', {
lbryio.setAccessToken(installation_id); language: 'en',
setCurrentUser(); app_id: installation_id,
}) }, 'post').then(function(responseData) {
.catch(function(error) { if (!responseData.id) {
/* reject(new Error("Received invalid authentication response."));
}
lbryio.setAccessToken(installation_id)
setLocal('auth_bypassed', false)
setCurrentUser()
}).catch(function(error) {
/*
until we have better error code format, assume all errors are duplicate application id until we have better error code format, assume all errors are duplicate application id
if we're wrong, this will be caught by later attempts to make a valid call if we're wrong, this will be caught by later attempts to make a valid call
*/ */
lbryio.setAccessToken(installation_id); lbryio.setAccessToken(installation_id);
setCurrentUser(); setCurrentUser();
}); });
} else { } else {
setCurrentUser(); setCurrentUser();
} }

View file

@ -3,6 +3,10 @@
$width-input-border: 2px; $width-input-border: 2px;
$width-input-text: 330px; $width-input-text: 330px;
.form-input-width {
width: $width-input-text
}
.form-row-submit .form-row-submit
{ {
margin-top: $spacing-vertical; margin-top: $spacing-vertical;