summaryrefslogtreecommitdiff
path: root/www/app/models/dummy_account.js
blob: bf0391be4bf21b0db7d471c507d4da93d8414f77 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
//
// 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.user.logout(this.address).then(
      response => {
        this._authenticated = false
        this._address = '@' + this.domain
        return this
      }
    )
  }
}