summaryrefslogtreecommitdiff
path: root/ui/app/models
diff options
context:
space:
mode:
Diffstat (limited to 'ui/app/models')
-rw-r--r--ui/app/models/account.js14
-rw-r--r--ui/app/models/dummy_account.js33
-rw-r--r--ui/app/models/provider.js8
3 files changed, 20 insertions, 35 deletions
diff --git a/ui/app/models/account.js b/ui/app/models/account.js
index 3656d2c7..14773602 100644
--- a/ui/app/models/account.js
+++ b/ui/app/models/account.js
@@ -4,6 +4,7 @@
//
import bitmask from 'lib/bitmask'
+import Provider from 'models/provider'
export default class Account {
@@ -46,8 +47,17 @@ export default class Account {
return this._authenticated
}
- get hasEmail() {
- return true
+ getProvider() {
+ if (this.provider) {
+ return new Promise((resolve, reject) => {
+ resolve(this.provider)
+ })
+ } else {
+ return Provider.get(this.domain).then(provider => {
+ this.provider = provider
+ return provider
+ })
+ }
}
//
diff --git a/ui/app/models/dummy_account.js b/ui/app/models/dummy_account.js
deleted file mode 100644
index 99fb6623..00000000
--- a/ui/app/models/dummy_account.js
+++ /dev/null
@@ -1,33 +0,0 @@
-//
-// A proxy of an account, but with a different ID. For testing.
-//
-
-import bitmask from 'lib/bitmask'
-
-export default class DummyAccount {
-
- constructor(account) {
- this.account = account
- }
-
- get id() {
- return 'dummy--' + this.account.address
- }
-
- get domain() {return this.account.domain}
- get address() {return this.account.address}
- get userpart() {return this.account.userpart}
- get authenticated() {return this.account.authenticated}
- get hasEmail() {return this.account.hasEmail}
- login(password) {return this.account.login(password)}
-
- logout() {
- return bitmask.bonafide.user.logout(this.address).then(
- response => {
- this._authenticated = false
- this._address = '@' + this.domain
- return this
- }
- )
- }
-}
diff --git a/ui/app/models/provider.js b/ui/app/models/provider.js
index 2ed2dc8c..af634339 100644
--- a/ui/app/models/provider.js
+++ b/ui/app/models/provider.js
@@ -23,6 +23,14 @@ export default class Provider {
return this._description[LOCALE]
}
+ get hasEmail() {
+ return this.services.includes("mx")
+ }
+
+ get hasVPN() {
+ return this.services.includes("openvpn")
+ }
+
static setup(domain) {
return bitmask.bonafide.provider.create(domain).then(
response => {