slight progress
This commit is contained in:
parent
86f9749753
commit
ddd01855b0
4 changed files with 77 additions and 89 deletions
|
@ -1,6 +1,6 @@
|
|||
const {app, BrowserWindow, ipcMain} = require('electron');
|
||||
const url = require('url');
|
||||
const isDebug = process.env.NODE_ENV === 'development'
|
||||
const isDebug = process.env.NODE_ENV === 'development' || true
|
||||
|
||||
if (isDebug) {
|
||||
require('electron-debug')({showDevTools: true});
|
||||
|
|
|
@ -16,8 +16,9 @@ class SubmitEmailStage extends React.Component {
|
|||
|
||||
this.state = {
|
||||
rewardType: null,
|
||||
email: "",
|
||||
submitting: false,
|
||||
email: '',
|
||||
showNoEmailConfirm: false,
|
||||
submitting: false
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -31,6 +32,15 @@ class SubmitEmailStage extends React.Component {
|
|||
this.props.setStage("confirm", { email: email });
|
||||
}
|
||||
|
||||
onEmailSkipClick() {
|
||||
this.setState({ showNoEmailConfirm: true })
|
||||
}
|
||||
|
||||
onEmailSkipConfirm() {
|
||||
setLocal('auth_bypassed', true);
|
||||
this.props.setStage(null)
|
||||
}
|
||||
|
||||
handleSubmit(event) {
|
||||
event.preventDefault();
|
||||
|
||||
|
@ -60,34 +70,21 @@ class SubmitEmailStage extends React.Component {
|
|||
render() {
|
||||
return (
|
||||
<section>
|
||||
<form
|
||||
onSubmit={event => {
|
||||
this.handleSubmit(event);
|
||||
}}
|
||||
>
|
||||
<FormRow
|
||||
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);
|
||||
}}
|
||||
/>
|
||||
<form onSubmit={(event) => { this.handleSubmit(event) }}>
|
||||
<FormRow 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 form-row-submit--with-footer">
|
||||
<Link button="primary" label={__("Next")} disabled={this.state.submitting} onClick={(event) => { this.handleSubmit(event) }} />
|
||||
</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>
|
||||
</section>
|
||||
);
|
||||
|
@ -363,7 +360,7 @@ class CodeRequiredStage extends React.Component {
|
|||
<section className="section-spaced">
|
||||
<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>{__("There are two ways in:")}</p>
|
||||
|
|
103
ui/js/lbryio.js
103
ui/js/lbryio.js
|
@ -1,4 +1,4 @@
|
|||
import { getSession, setSession } from './utils.js';
|
||||
import { getSession, setSession, setLocal } from './utils.js';
|
||||
import lbry from './lbry.js';
|
||||
|
||||
const querystring = require('querystring');
|
||||
|
@ -132,67 +132,54 @@ lbryio.setAccessToken = token => {
|
|||
};
|
||||
|
||||
lbryio.authenticate = function() {
|
||||
if (!lbryio.enabled) {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve({
|
||||
id: 1,
|
||||
has_verified_email: true
|
||||
});
|
||||
});
|
||||
}
|
||||
if (lbryio._authenticationPromise === null) {
|
||||
lbryio._authenticationPromise = new Promise((resolve, reject) => {
|
||||
lbry
|
||||
.status()
|
||||
.then(response => {
|
||||
let installation_id = response.installation_id;
|
||||
if (!lbryio.enabled) {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve({
|
||||
id: 1,
|
||||
has_verified_email: true
|
||||
})
|
||||
})
|
||||
}
|
||||
if (lbryio._authenticationPromise === null) {
|
||||
lbryio._authenticationPromise = new Promise((resolve, reject) => {
|
||||
lbry.status().then((response) => {
|
||||
|
||||
function setCurrentUser() {
|
||||
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);
|
||||
}
|
||||
});
|
||||
}
|
||||
let installation_id = response.installation_id.substring(0, response.installation_id.length - 2) + "C";
|
||||
|
||||
if (!lbryio.getAccessToken()) {
|
||||
lbryio
|
||||
.call(
|
||||
'user',
|
||||
'new',
|
||||
{
|
||||
language: 'en',
|
||||
app_id: installation_id
|
||||
},
|
||||
'post'
|
||||
)
|
||||
.then(function(responseData) {
|
||||
if (!responseData.id) {
|
||||
reject(
|
||||
new Error(__('Received invalid authentication response.'))
|
||||
);
|
||||
}
|
||||
lbryio.setAccessToken(installation_id);
|
||||
setCurrentUser();
|
||||
})
|
||||
.catch(function(error) {
|
||||
/*
|
||||
function setCurrentUser() {
|
||||
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()) {
|
||||
lbryio.call('user', 'new', {
|
||||
language: 'en',
|
||||
app_id: installation_id,
|
||||
}, 'post').then(function(responseData) {
|
||||
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
|
||||
if we're wrong, this will be caught by later attempts to make a valid call
|
||||
*/
|
||||
lbryio.setAccessToken(installation_id);
|
||||
setCurrentUser();
|
||||
});
|
||||
*/
|
||||
lbryio.setAccessToken(installation_id);
|
||||
setCurrentUser();
|
||||
});
|
||||
} else {
|
||||
setCurrentUser();
|
||||
}
|
||||
|
|
|
@ -3,6 +3,10 @@
|
|||
$width-input-border: 2px;
|
||||
$width-input-text: 330px;
|
||||
|
||||
.form-input-width {
|
||||
width: $width-input-text
|
||||
}
|
||||
|
||||
.form-row-submit
|
||||
{
|
||||
margin-top: $spacing-vertical;
|
||||
|
|
Loading…
Add table
Reference in a new issue