diff options
| -rw-r--r-- | app/components/Connect.js | 10 | ||||
| -rw-r--r-- | app/lib/backend.js | 7 |
2 files changed, 11 insertions, 6 deletions
diff --git a/app/components/Connect.js b/app/components/Connect.js index c5d435823e..8e4e400fce 100644 --- a/app/components/Connect.js +++ b/app/components/Connect.js @@ -1,4 +1,5 @@ import assert from 'assert'; +import moment from 'moment'; import React, { Component, PropTypes } from 'react'; import { If, Then, Else } from 'react-if'; import ReactMapboxGl, { Marker } from 'react-mapbox-gl'; @@ -49,10 +50,19 @@ export default class Connect extends Component { render() { let error = null; + // check if user out of time + // this is by far the simplest implementation + // later on backend will notify us and disconnect VPN etc.. + if(moment(this.props.user.paidUntil).isSameOrBefore(moment())) { + error = new Backend.Error(Backend.ErrorType.noCredit); + } + + // Connection error? if(this.props.connect.status === ConnectionState.failed) { error = this.props.connect.error; } + // Offline? if(this.props.connect.isOnline === false) { error = new Backend.Error(Backend.ErrorType.noInternetConnection); } diff --git a/app/lib/backend.js b/app/lib/backend.js index 400e2bdfc9..0151bf2cda 100644 --- a/app/lib/backend.js +++ b/app/lib/backend.js @@ -408,12 +408,7 @@ export default class Backend extends EventEmitter { timer = setTimeout(() => { let err = null; - - // Prototype: the US servers will throw error during connect - if(/us\d+\.mullvad\.net/.test(addr)) { - err = new BackendError(Backend.ErrorType.noCredit); - } - + this._connStatus = Backend.ConnectionState.connected; // emit: connect |
