summaryrefslogtreecommitdiff
path: root/ui/app/models/account.js
diff options
context:
space:
mode:
authorelijah <elijah@riseup.net>2016-09-29 11:56:44 -0700
committerelijah <elijah@riseup.net>2016-09-29 11:58:51 -0700
commite7281dd47f375c1b0a72ae85505319c4d87fb524 (patch)
tree8cc4c3967eebefd26eaaedabbfd41ea4cde0390d /ui/app/models/account.js
parentbf6571764fc0d7c0ef0153e3e5e9174221aa167d (diff)
[feat] ui - improved account list, show multiple login sessions
Diffstat (limited to 'ui/app/models/account.js')
-rw-r--r--ui/app/models/account.js35
1 files changed, 27 insertions, 8 deletions
diff --git a/ui/app/models/account.js b/ui/app/models/account.js
index 726a8b8c..04c8163e 100644
--- a/ui/app/models/account.js
+++ b/ui/app/models/account.js
@@ -57,11 +57,6 @@ export default class Account {
return bitmask.bonafide.user.auth(this.address, password).then(
response => {
if (response.uuid) {
- // currently, only one account can be authenticated at once
- Account.list.forEach(account => {
- account._authenticated = false
- // if(account.id != this.id) {account.logout()}
- })
this._uuid = response.uuid
this._authenticated = true
}
@@ -84,8 +79,7 @@ export default class Account {
}
//
- // returns the matching account in the list of accounts, or adds it
- // if it is not already present.
+ // returns the matching account in the list of accounts
//
static find(address) {
// search by full address
@@ -102,7 +96,11 @@ export default class Account {
account.address = address
}
}
- // failing that, create new account
+ return account
+ }
+
+ static find_or_add(address) {
+ let account = Account.find(address)
if (!account) {
account = new Account(address)
Account.list.push(account)
@@ -116,6 +114,7 @@ export default class Account {
static active() {
return bitmask.bonafide.user.active().then(
response => {
+ console.log(response)
if (response.user == '<none>') {
return null
} else {
@@ -145,6 +144,26 @@ export default class Account {
}
)
}
+
+ static initialize_list(domains) {
+ for (let domain of domains) {
+ Account.add(new Account(domain))
+ }
+ }
+
+ //
+ // inserts at the front of the account list
+ // removing any other accounts with the same domain.
+ //
+ // this is a temporary hack to support the old behavior
+ // util the backend has a proper concept of an account list.
+ //
+ static add_primary(account) {
+ Account.list = Account.list.filter(i => {
+ return i.domain != account.domain
+ })
+ Account.list.unshift(account)
+ }
}
Account.list = []