From e7281dd47f375c1b0a72ae85505319c4d87fb524 Mon Sep 17 00:00:00 2001 From: elijah Date: Thu, 29 Sep 2016 11:56:44 -0700 Subject: [feat] ui - improved account list, show multiple login sessions --- ui/app/models/account.js | 35 +++++++++++++++++++++++++++-------- 1 file changed, 27 insertions(+), 8 deletions(-) (limited to 'ui/app/models/account.js') diff --git a/ui/app/models/account.js b/ui/app/models/account.js index 726a8b8..04c8163 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 == '') { 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 = [] -- cgit v1.2.3