diff --git a/js/src/3rdparty/email-verification/index.js b/js/src/3rdparty/email-verification/index.js index ca1b04138..d49ba3197 100644 --- a/js/src/3rdparty/email-verification/index.js +++ b/js/src/3rdparty/email-verification/index.js @@ -16,6 +16,19 @@ import { stringify } from 'querystring'; +export const isServerRunning = (isTestnet = false) => { + const port = isTestnet ? 28443 : 18443; + return fetch(`https://email-verification.parity.io:${port}/health`, { + mode: 'cors', cache: 'no-store' + }) + .then((res) => { + return res.ok; + }) + .catch(() => { + return false; + }); +}; + export const postToServer = (query, isTestnet = false) => { const port = isTestnet ? 28443 : 18443; query = stringify(query); diff --git a/js/src/3rdparty/sms-verification/index.js b/js/src/3rdparty/sms-verification/index.js index 23e978972..ed890631f 100644 --- a/js/src/3rdparty/sms-verification/index.js +++ b/js/src/3rdparty/sms-verification/index.js @@ -16,6 +16,19 @@ import { stringify } from 'querystring'; +export const isServerRunning = (isTestnet = false) => { + const port = isTestnet ? 8443 : 443; + return fetch(`https://sms-verification.parity.io:${port}/health`, { + mode: 'cors', cache: 'no-store' + }) + .then((res) => { + return res.ok; + }) + .catch(() => { + return false; + }); +}; + export const postToServer = (query, isTestnet = false) => { const port = isTestnet ? 8443 : 443; query = stringify(query); diff --git a/js/src/modals/Verification/GatherData/gatherData.js b/js/src/modals/Verification/GatherData/gatherData.js index 57386ed20..888585fcc 100644 --- a/js/src/modals/Verification/GatherData/gatherData.js +++ b/js/src/modals/Verification/GatherData/gatherData.js @@ -15,6 +15,7 @@ // along with Parity. If not, see . import React, { Component, PropTypes } from 'react'; +import { FormattedMessage } from 'react-intl'; import BigNumber from 'bignumber.js'; import { Checkbox } from 'material-ui'; import InfoIcon from 'material-ui/svg-icons/action/info-outline'; @@ -33,10 +34,11 @@ import styles from './gatherData.css'; export default class GatherData extends Component { static propTypes = { fee: React.PropTypes.instanceOf(BigNumber), - method: PropTypes.string.isRequired, fields: PropTypes.array.isRequired, - isVerified: nullableProptype(PropTypes.bool.isRequired), hasRequested: nullableProptype(PropTypes.bool.isRequired), + isServerRunning: nullableProptype(PropTypes.bool.isRequired), + isVerified: nullableProptype(PropTypes.bool.isRequired), + method: PropTypes.string.isRequired, setConsentGiven: PropTypes.func.isRequired } @@ -48,13 +50,19 @@ export default class GatherData extends Component { return (
{ howItWorks } + { this.renderServerRunning() } { this.renderFee() } { this.renderCertified() } { this.renderRequested() } { this.renderFields() } + } disabled={ isVerified } onCheck={ this.consentOnChange } /> @@ -63,6 +71,44 @@ export default class GatherData extends Component { ); } + renderServerRunning () { + const { isServerRunning } = this.props; + + if (isServerRunning) { + return ( +
+ +

+ +

+
+ ); + } else if (isServerRunning === false) { + return ( +
+ +

+ +

+
+ ); + } + return ( +

+ +

+ ); + } + renderFee () { const { fee } = this.props; @@ -72,7 +118,15 @@ export default class GatherData extends Component { return (
-

The fee is { fromWei(fee).toFixed(3) } ETH.

+

+ +

); } @@ -84,19 +138,34 @@ export default class GatherData extends Component { return (
-

Your account is already verified.

+

+ +

); } else if (isVerified === false) { return (
-

Your account is not verified yet.

+

+ +

); } return ( -

Checking if your account is verified…

+

+ +

); } @@ -112,19 +181,34 @@ export default class GatherData extends Component { return (
-

You already requested verification.

+

+ +

); } else if (hasRequested === false) { return (
-

You did not request verification yet.

+

+ +

); } return ( -

Checking if you requested verification…

+

+ +

); } diff --git a/js/src/modals/Verification/email-store.js b/js/src/modals/Verification/email-store.js index 5360ad611..07a6baaad 100644 --- a/js/src/modals/Verification/email-store.js +++ b/js/src/modals/Verification/email-store.js @@ -21,7 +21,7 @@ import EmailVerificationABI from '~/contracts/abi/email-verification.json'; import VerificationStore, { LOADING, QUERY_DATA, QUERY_CODE, POSTED_CONFIRMATION, DONE } from './store'; -import { postToServer } from '../../3rdparty/email-verification'; +import { isServerRunning, postToServer } from '../../3rdparty/email-verification'; const EMAIL_VERIFICATION = 7; // id in the `BadgeReg.sol` contract @@ -59,6 +59,10 @@ export default class EmailVerificationStore extends VerificationStore { super(api, EmailVerificationABI, EMAIL_VERIFICATION, account, isTestnet); } + isServerRunning = () => { + return isServerRunning(this.isTestnet); + } + requestValues = () => [ sha3.text(this.email) ] @action setEmail = (email) => { diff --git a/js/src/modals/Verification/sms-store.js b/js/src/modals/Verification/sms-store.js index 7b1b859db..3aa338ef2 100644 --- a/js/src/modals/Verification/sms-store.js +++ b/js/src/modals/Verification/sms-store.js @@ -21,7 +21,7 @@ import SMSVerificationABI from '~/contracts/abi/sms-verification.json'; import VerificationStore, { LOADING, QUERY_DATA, QUERY_CODE, POSTED_CONFIRMATION, DONE } from './store'; -import { postToServer } from '../../3rdparty/sms-verification'; +import { isServerRunning, postToServer } from '../../3rdparty/sms-verification'; const SMS_VERIFICATION = 0; // id in the `BadgeReg.sol` contract @@ -58,6 +58,10 @@ export default class SMSVerificationStore extends VerificationStore { super(api, SMSVerificationABI, SMS_VERIFICATION, account, isTestnet); } + isServerRunning = () => { + return isServerRunning(this.isTestnet); + } + @action setNumber = (number) => { this.number = number; } diff --git a/js/src/modals/Verification/store.js b/js/src/modals/Verification/store.js index 06250fd76..eeec71788 100644 --- a/js/src/modals/Verification/store.js +++ b/js/src/modals/Verification/store.js @@ -40,6 +40,7 @@ export default class VerificationStore { @observable fee = null; @observable isVerified = null; @observable hasRequested = null; + @observable isServerRunning = null; @observable consentGiven = false; @observable requestTx = null; @observable code = ''; @@ -73,6 +74,14 @@ export default class VerificationStore { const { contract, account } = this; this.step = LOADING; + const isServerRunning = this.isServerRunning() + .then((isRunning) => { + this.isServerRunning = isRunning; + }) + .catch((err) => { + this.error = 'Failed to check if server is running: ' + err.message; + }); + const fee = contract.instance.fee.call() .then((fee) => { this.fee = fee; @@ -101,7 +110,7 @@ export default class VerificationStore { }); Promise - .all([ fee, isVerified, hasRequested ]) + .all([ isServerRunning, fee, isVerified, hasRequested ]) .then(() => { this.step = QUERY_DATA; }); diff --git a/js/src/modals/Verification/verification.js b/js/src/modals/Verification/verification.js index 0fac3bf75..e6e32d148 100644 --- a/js/src/modals/Verification/verification.js +++ b/js/src/modals/Verification/verification.js @@ -94,10 +94,10 @@ class Verification extends Component { return ( { this.renderStep(phase, error) } @@ -111,8 +111,9 @@ class Verification extends Component { const cancel = (