diff options
| author | Andrej Mihajlov <and@mullvad.net> | 2017-11-30 17:38:08 +0100 |
|---|---|---|
| committer | Andrej Mihajlov <and@mullvad.net> | 2017-12-06 13:36:25 +0100 |
| commit | 345250b46fad88ee9eb77b32a48b60f9590b5b52 (patch) | |
| tree | 4657d3a1ecd4c1e3df9d87b0f2d9626b252b0748 | |
| parent | 841dabe013f278161298d4781ff29be125b25fad (diff) | |
| download | mullvadvpn-345250b46fad88ee9eb77b32a48b60f9590b5b52.tar.xz mullvadvpn-345250b46fad88ee9eb77b32a48b60f9590b5b52.zip | |
Convert Backend.logout() to async
| -rw-r--r-- | app/lib/backend.js | 29 |
1 files changed, 13 insertions, 16 deletions
diff --git a/app/lib/backend.js b/app/lib/backend.js index 3fb2992c22..bc357ab36a 100644 --- a/app/lib/backend.js +++ b/app/lib/backend.js @@ -256,24 +256,21 @@ export class Backend { } } - logout() { + async logout() { // @TODO: What does it mean for a logout to be successful or failed? - return this._ensureAuthenticated() - .then( () => { - return this._ipc.setAccount(null) - .then(() => { - this._store.dispatch(accountActions.loggedOut()); + try { + await this._ensureAuthenticated(); + await this._ipc.setAccount(null); - // disconnect user during logout - return this.disconnect() - .then( () => { - this._store.dispatch(push('/')); - }); - }) - .catch(e => { - log.info('Failed to logout,', e.message); - }); - }); + this._store.dispatch(accountActions.loggedOut()); + + // disconnect user during logout + await this.disconnect(); + + this._store.dispatch(push('/')); + } catch (e) { + log.info('Failed to logout: ', e.message); + } } connect(): Promise<void> { |
