From 7569ac8bd58174095f3f897548e26d0ba905236c Mon Sep 17 00:00:00 2001 From: elijah Date: Wed, 21 Sep 2016 15:39:03 -0700 Subject: [feat] the setup wizard for the new ui --- ui/app/models/account.js | 21 +++++++++++------ ui/app/models/provider.js | 59 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 73 insertions(+), 7 deletions(-) create mode 100644 ui/app/models/provider.js (limited to 'ui/app/models') diff --git a/ui/app/models/account.js b/ui/app/models/account.js index 52fea93..726a8b8 100644 --- a/ui/app/models/account.js +++ b/ui/app/models/account.js @@ -57,6 +57,11 @@ 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 } @@ -131,13 +136,15 @@ export default class Account { return i.id != account.id }) } - // return Account.list - // return new Promise(function(resolve, reject) { - // window.setTimeout(function() { - // resolve(['@blah', '@lala']) - // }, 1000) - // }) - // } + + static create(address, password) { + return bitmask.bonafide.user.create(address, password).then( + response => { + console.log(response) + return new Account(address) + } + ) + } } Account.list = [] diff --git a/ui/app/models/provider.js b/ui/app/models/provider.js new file mode 100644 index 0000000..2ed2dc8 --- /dev/null +++ b/ui/app/models/provider.js @@ -0,0 +1,59 @@ +import bitmask from 'lib/bitmask' + +var LOCALE = 'en' + +export default class Provider { + + constructor(props) { + this._name = props.name + this._description = props.description + let k = null + for (k in props) { + if (k != 'description' && k != 'name') { + this[k] = props[k] + } + } + } + + get name() { + return this._name[LOCALE] + } + + get description() { + return this._description[LOCALE] + } + + static setup(domain) { + return bitmask.bonafide.provider.create(domain).then( + response => { + console.log("Provider configured: " + response.domain) + return new Provider(response) + } + ) + } + + static get(domain) { + return bitmask.bonafide.provider.read(domain).then( + response => { + return new Provider(response) + } + ) + } + + static list(seeded=false) { + return bitmask.bonafide.provider.list(seeded).then( + response => { + return response.map( + i => { return i['domain'] } + ) + } + ) + } + + static delete(domain) { + return bitmask.bonafide.provider.delete(domain) + } +} + + + -- cgit v1.2.3