diff options
| author | Andrej Mihajlov <and@codeispoetry.ru> | 2017-03-21 18:14:15 +0000 |
|---|---|---|
| committer | Andrej Mihajlov <and@codeispoetry.ru> | 2017-03-21 18:14:15 +0000 |
| commit | cf235a151d4f5d67f1e8e1656e831cdfbc17a22d (patch) | |
| tree | 39d85d696da3c9260a7cb1974f8dbe49ac4859a8 | |
| parent | fca751a517b2b35b8316b5c1f5dab8f7a130953d (diff) | |
| download | mullvadvpn-cf235a151d4f5d67f1e8e1656e831cdfbc17a22d.tar.xz mullvadvpn-cf235a151d4f5d67f1e8e1656e831cdfbc17a22d.zip | |
Display user out of time error
| -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 |
