diff --git a/app/components/App.jsx b/app/components/App.jsx index 48f573320bfa5ee1a0062719d9c63b74a398f997..5f0eb0d6c4c9ad003d3ce5b750e941ec101d93e5 100644 --- a/app/components/App.jsx +++ b/app/components/App.jsx @@ -136,7 +136,7 @@ class App extends React.Component { <h2>{translate("welcome_to_the_blockchain")}</h2> <h4>{translate("your_voice_is_worth_something")}</h4> <br /> - <a className="button" href="/create_account" onClick={showSignUp}> <b>{translate("sign_up")}</b> </a> + <a className="button" href="/enter_email"> <b>{translate("sign_up")}</b> </a> <a className="button hollow uppercase" href="https://steem.io" target="_blank"> <b>{translate("learn_more")}</b> </a> <br /> diff --git a/app/components/elements/SignupProgressBar.scss b/app/components/elements/SignupProgressBar.scss index a744e8e192c88aa575657882ebf2e527f8aa3785..dcc11c98ec70fa2f0067bad98c71a3532a50cfc5 100644 --- a/app/components/elements/SignupProgressBar.scss +++ b/app/components/elements/SignupProgressBar.scss @@ -13,7 +13,7 @@ } > ul > li { list-style-type: none; - width: 25%; + width: 33%; float: left; font-size: 12px; position: relative; @@ -52,20 +52,22 @@ } > ul > li.done:before { content: "\2713"; - color: #fff; - border-color: #4ba2f2; - background-color: #4ba2f2; + color: $white; + border-color: #1A5099; + background-color: #1A5099; } > ul > li.done:after { - background-color: #4ba2f2; + background-color: #1A5099; } > ul > li.current { color: #1A5099; } > ul > li.current:before { + color: $white; border-color: #4ba2f2; + background-color: #4ba2f2; } > ul > li.current:after { - background-color: #4ba2f2; + background-color: #1A5099; } } diff --git a/app/components/modules/Header.jsx b/app/components/modules/Header.jsx index ba88e0441670577a0d4b08f01055bea3a3285a5f..450270fdc506de759785584fb6531e815ade65c1 100644 --- a/app/components/modules/Header.jsx +++ b/app/components/modules/Header.jsx @@ -108,7 +108,7 @@ class Header extends React.Component { } else if (route.page == 'ChangePassword') { page_title = `Change Account Password`; } else if (route.page == 'CreateAccount') { - page_title = `Sign Up`; + page_title = `Create Account`; } else if (route.page == 'RecoverAccountStep1' || route.page == 'RecoverAccountStep2') { page_title = `Stolen Account Recovery`; } else if (route.page === 'UserProfile') { diff --git a/app/components/modules/TopRightMenu.jsx b/app/components/modules/TopRightMenu.jsx index 52b9fe778948dc9c68cd9787f0d6145e454d0dd8..c2846cc923dbf1ac9a7e140d57a4866139415bc2 100644 --- a/app/components/modules/TopRightMenu.jsx +++ b/app/components/modules/TopRightMenu.jsx @@ -78,7 +78,7 @@ function TopRightMenu({username, showLogin, logout, loggedIn, showSignUp, userpi return ( <ul className={mcn + mcl}> {!vertical && <li><a href="/static/search.html" title="Search"><Icon name="search" /></a></li>} - <li className={lcn}><a href="/create_account" onClick={showSignUp}>Sign Up</a></li> + <li className={lcn}><a href="/enter_email">Sign Up</a></li> <li className={lcn}><a href="/login.html" onClick={showLogin}>Login</a></li> {submit_story} {toggleOffCanvasMenu && <li className="toggle-menu"><a href="#" onClick={toggleOffCanvasMenu}> diff --git a/app/components/pages/CreateAccount.jsx b/app/components/pages/CreateAccount.jsx index 38638bf7724488642366e57e3987ce79a113d9a1..999b3ac2d4a705b6889b7425451c13bbbcd9cfaa 100644 --- a/app/components/pages/CreateAccount.jsx +++ b/app/components/pages/CreateAccount.jsx @@ -202,18 +202,27 @@ class CreateAccount extends React.Component { </div>; } - const next_step = !server_error ? null : - server_error === 'Mobile is not confirmed' ? <div> - <a href="/enter_mobile">Verify a Mobile</a> - </div> : <div className="callout alert"> - <h5>Couldn't create account. Server returned the following error:</h5> - <p>{server_error}</p> - {server_error === 'Email address is not confirmed' && <a href="/enter_email">Confirm Email</a>} - </div> + let next_step = null; + if (server_error) { + if (server_error === 'Email address is not confirmed') { + next_step = <div className="callout alert"> + <a href="/enter_email">Please verify your email address</a> + </div>; + } else if (server_error === 'Phone number is not confirmed') { + next_step = <div className="callout alert"> + <a href="/enter_mobile">Please verify your phone number</a> + </div>; + } else { + next_step = <div className="callout alert"> + <h5>Couldn't create account. Server returned the following error:</h5> + <p>{server_error}</p> + </div>; + } + } return ( <div> - <SignupProgressBar steps={[offchainUser.get('prv') || 'identity', 'email', 'phone', 'steem account']} current={4} /> + <SignupProgressBar steps={['email', 'phone', 'steem account']} current={3} /> <div className="CreateAccount row"> <div className="column" style={{maxWidth: '36rem', margin: '0 auto'}}> <br /> diff --git a/server/server_pages/enter_confirm_email.jsx b/server/server_pages/enter_confirm_email.jsx index c1ab1e73dd8a474fd7a1e1ef6e6be17c81c60085..0bb7d32ed2643c5a43e5ac72ff51611f43ee5fc7 100644 --- a/server/server_pages/enter_confirm_email.jsx +++ b/server/server_pages/enter_confirm_email.jsx @@ -7,7 +7,7 @@ import models from 'db/models'; import {esc, escAttrs} from 'db/models'; import ServerHTML from '../server-html'; import sendEmail from '../sendEmail'; -import {checkCSRF} from '../utils'; +import {checkCSRF, getRemoteIp} from '../utils'; import config from '../../config'; import SignupProgressBar from 'app/components/elements/SignupProgressBar'; import MiniHeader from 'app/components/modules/MiniHeader'; @@ -51,25 +51,23 @@ export default function useEnterAndConfirmEmailPages(app) { router.get('/enter_email', function *() { console.log('-- /enter_email -->', this.session.uid, this.session.user); + let eid = null; const user_id = this.session.user; - if (!user_id) { - this.body = 'user not found'; - return; - } - const eid = yield models.Identity.findOne( - {attributes: ['email', 'verified'], where: {user_id, provider: 'email'}, order: 'id DESC'} - ); - if (eid && eid.verified) { - this.flash = {success: 'Email has already been verified'}; - this.redirect('/enter_mobile'); - return; + if (user_id) { + eid = yield models.Identity.findOne( + {attributes: ['email', 'verified'], where: {user_id, provider: 'email'}, order: 'id DESC'} + ); + if (eid && eid.verified) { + this.flash = {success: 'Email has already been verified'}; + this.redirect('/enter_mobile'); + return; + } } - console.log('-- this.request.query -->', this.request.query); let default_email = ''; if (this.request.query && this.request.query.email) default_email = this.request.query.email; const body = renderToString(<div className="App"> <MiniHeader /> - <SignupProgressBar steps={[this.session.prv || 'identity', 'email', 'phone', 'steem account']} current={2} /> + <SignupProgressBar steps={['email', 'phone', 'steem account']} current={1} /> <br /> <div className="row" style={{maxWidth: '32rem'}}> <div className="column"> @@ -83,8 +81,6 @@ export default function useEnterAndConfirmEmailPages(app) { Email <input type="email" name="email" defaultValue={default_email} /> </label> - {/*eid && eid.email && - <div className="secondary"><i>Email address cannot be changed at this moment, sorry for the inconvenience.</i></div>*/} <br /> <div className="g-recaptcha" data-sitekey={config.recaptcha.site_key}></div> <br /> @@ -100,11 +96,7 @@ export default function useEnterAndConfirmEmailPages(app) { router.post('/submit_email', koaBody, function *() { if (!checkCSRF(this, this.request.body.csrf)) return; - const user_id = this.session.user; - if (!user_id) { - this.body = 'user not found'; - return; - } + const email = this.request.body.email; if (!email) { this.flash = {error: 'Please provide an email address'}; @@ -161,6 +153,19 @@ export default function useEnterAndConfirmEmailPages(app) { return; } + let user_id = this.session.user; + if (user_id) { + const user = yield models.User.findOne({attributes: ['id'], where: {id: user_id}}); + if (!user) user_id = null; + } + if (!user_id) { + const user = yield models.User.create({ + uid: this.session.uid, + remote_ip: getRemoteIp(this.request.req) + }); + this.session.user = user_id = user.id; + } + const confirmation_code = Math.random().toString(36).slice(2); let eid = yield models.Identity.findOne( {attributes: ['id', 'email'], where: {user_id, provider: 'email'}, order: 'id'} @@ -182,7 +187,7 @@ export default function useEnterAndConfirmEmailPages(app) { const body = renderToString(<div className="App"> <MiniHeader /> - <SignupProgressBar steps={[this.session.prv || 'identity', 'email', 'phone', 'steem account']} current={2} /> + <SignupProgressBar steps={['email', 'phone', 'steem account']} current={1} /> <br /> <div className="row" style={{maxWidth: '32rem'}}> <div className="column"> diff --git a/server/server_pages/enter_confirm_mobile.jsx b/server/server_pages/enter_confirm_mobile.jsx index fd23b30b83f0444b621fe7e51b9be4c5c7ca5b20..95fec93226165dd2c6a8cc34c6d84017b8235156 100644 --- a/server/server_pages/enter_confirm_mobile.jsx +++ b/server/server_pages/enter_confirm_mobile.jsx @@ -1,11 +1,9 @@ import koa_router from 'koa-router'; import koa_body from 'koa-body'; -import request from 'co-request'; import React from 'react'; import {renderToString} from 'react-dom/server'; import models from 'db/models'; import ServerHTML from 'server/server-html'; -import Icon from 'app/components/elements/Icon.jsx'; import {verify} from 'server/teleSign'; import SignupProgressBar from 'app/components/elements/SignupProgressBar'; import {getRemoteIp, checkCSRF} from 'server/utils'; @@ -13,7 +11,6 @@ import MiniHeader from 'app/components/modules/MiniHeader'; const assets_file = process.env.NODE_ENV === 'production' ? 'tmp/webpack-stats-prod.json' : 'tmp/webpack-stats-dev.json'; const assets = Object.assign({}, require(assets_file), {script: []}); -// assets.script.push('https://www.google.com/recaptcha/api.js'); function *confirmMobileHandler() { const confirmation_code = this.params && this.params.code ? this.params.code : this.request.body.code; @@ -22,8 +19,8 @@ function *confirmMobileHandler() { {attributes: ['id', 'user_id', 'verified', 'updated_at'], where: {user_id: this.session.user, confirmation_code}, order: 'id DESC'} ); if (!mid) { - this.status = 401; - this.body = 'Wrong confirmation code'; + this.flash = {error: 'Wrong confirmation code.'}; + this.redirect('/enter_mobile'); return; } if (mid.verified) { @@ -61,7 +58,7 @@ export default function useEnterAndConfirmMobilePages(app) { } const body = renderToString(<div className="App"> <MiniHeader /> - <SignupProgressBar steps={[this.session.prv || 'identity', 'email', 'phone', 'steem account']} current={3} /> + <SignupProgressBar steps={['email', 'phone', 'steem account']} current={2} /> <br /> <div className="row" style={{maxWidth: '32rem'}}> <form className="column" action="/submit_mobile" method="POST"> @@ -76,10 +73,9 @@ export default function useEnterAndConfirmMobilePages(app) { </label> <div className="secondary">Examples: 1-541-754-3010 | +1-541-754-3010 | +49-89-636-48018</div> <br /> - <div className="secondary">* fixed line phones cannot receive SMS messages</div> - <div className="secondary">* message and data rates may apply</div> + <div className="secondary">* Land lines cannot receive SMS messages</div> + <div className="secondary">* Message and data rates may apply</div> <br /> - {/*<div className="g-recaptcha" data-sitekey={config.recaptcha.site_key}></div>*/} <div className="error">{this.flash.error}</div> <input type="submit" className="button" value="CONTINUE" /> </form> @@ -95,7 +91,7 @@ export default function useEnterAndConfirmMobilePages(app) { if (!user_id) { this.body = 'user not found'; return; } let mobile = this.request.body.mobile; if (!mobile) { - this.flash = {error: 'Please provide a mobile number'}; + this.flash = {error: 'Please provide a phone number'}; this.redirect('/enter_mobile'); return; } @@ -120,24 +116,6 @@ export default function useEnterAndConfirmMobilePages(app) { return; } - // const recaptcha = this.request.body['g-recaptcha-response']; - // const verificationUrl = 'https://www.google.com/recaptcha/api/siteverify?secret=' + config.recaptcha.secret_key + '&response=' + recaptcha + '&remoteip=' + this.req.connection.remoteAddress; - // let captcha_failed; - // try { - // const recaptcha_res = yield request(verificationUrl); - // const body = JSON.parse(recaptcha_res.body); - // captcha_failed = !body.success; - // } catch (e) { - // captcha_failed = true; - // console.error('-- /submit_mobile recaptcha request failed -->', verificationUrl, e); - // } - // if (captcha_failed) { - // console.log('-- /submit_mobile captcha verification failed -->', user_id, this.session.uid, mobile, this.req.connection.remoteAddress); - // this.flash = {error: 'Failed captcha verification, please try again.'}; - // this.redirect('/enter_mobile'); - // return; - // } - const existing_phone = yield models.Identity.findOne( {attributes: ['user_id'], where: {phone: mobile, provider: 'phone', verified: true}, order: 'id'} ); @@ -159,7 +137,7 @@ export default function useEnterAndConfirmMobilePages(app) { } else { const seconds_ago = (Date.now() - mid.updated_at) / 1000.0; if (seconds_ago < 120) { - this.flash = {error: 'Confirmation was sent a moment ago. You can try again only in 2 minutes.'}; + this.flash = {error: 'Confirmation was attempted a moment ago. You can try again only in 2 minutes.'}; this.redirect('/enter_mobile'); return; } @@ -179,8 +157,8 @@ export default function useEnterAndConfirmMobilePages(app) { const ip = getRemoteIp(this.req) const verifyResult = yield verify({mobile, confirmation_code, ip}); - if (verifyResult && verifyResult.score) eid.update({score: verifyResult.score}); - if(verifyResult && verifyResult.error) { + if (verifyResult && verifyResult.score) mid.update({score: verifyResult.score}); + if (verifyResult && verifyResult.error) { this.flash = {error: verifyResult.error}; this.redirect('/enter_mobile'); return; @@ -188,7 +166,7 @@ export default function useEnterAndConfirmMobilePages(app) { const body = renderToString(<div className="App"> <MiniHeader /> - <SignupProgressBar steps={[this.session.prv || 'identity', 'email', 'phone', 'steem account']} current={3} /> + <SignupProgressBar steps={['email', 'phone', 'steem account']} current={2} /> <br /> <div className="row" style={{maxWidth: '32rem'}}> <div className="column">