aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorJohannes Zellner <johannes@cloudron.io>2018-10-08 16:09:42 +0200
committerJohannes Zellner <johannes@cloudron.io>2018-10-08 16:09:42 +0200
commit996e13b351ddcc106e4700adc6257d0815e2cd23 (patch)
treede583771f03120cad9c3b2c8cd0bbdfb6fbfa8c4
parentc66d70933dbd80ec734f4986f92369ff1e549bbb (diff)
downloadSurfer-996e13b351ddcc106e4700adc6257d0815e2cd23.tar.gz
Surfer-996e13b351ddcc106e4700adc6257d0815e2cd23.tar.zst
Surfer-996e13b351ddcc106e4700adc6257d0815e2cd23.zip
Fix logout situation if token is invalid
-rw-r--r--frontend/js/app.js25
1 files changed, 16 insertions, 9 deletions
diff --git a/frontend/js/app.js b/frontend/js/app.js
index be5705f..0a6ada1 100644
--- a/frontend/js/app.js
+++ b/frontend/js/app.js
@@ -1,6 +1,11 @@
1(function () { 1(function () {
2'use strict'; 2'use strict';
3 3
4/* global superagent */
5/* global Vue */
6/* global $ */
7/* global filesize */
8
4// poor man's async 9// poor man's async
5function asyncForEach(items, handler, callback) { 10function asyncForEach(items, handler, callback) {
6 var cur = 0; 11 var cur = 0;
@@ -86,6 +91,16 @@ function refresh() {
86 loadDirectory(app.path); 91 loadDirectory(app.path);
87} 92}
88 93
94function logout() {
95 superagent.post('/api/logout').query({ access_token: localStorage.accessToken }).end(function (error) {
96 if (error) console.error(error);
97
98 app.session.valid = false;
99
100 delete localStorage.accessToken;
101 });
102}
103
89function loadDirectory(filePath) { 104function loadDirectory(filePath) {
90 app.busy = true; 105 app.busy = true;
91 106
@@ -278,8 +293,6 @@ var app = new Vue({
278 }); 293 });
279 }, 294 },
280 onOptionsMenu: function (command) { 295 onOptionsMenu: function (command) {
281 var that = this;
282
283 if (command === 'folderListing') { 296 if (command === 'folderListing') {
284 superagent.put('/api/settings').send({ folderListingEnabled: this.folderListingEnabled }).query({ access_token: localStorage.accessToken }).end(function (error) { 297 superagent.put('/api/settings').send({ folderListingEnabled: this.folderListingEnabled }).query({ access_token: localStorage.accessToken }).end(function (error) {
285 if (error) console.error(error); 298 if (error) console.error(error);
@@ -295,13 +308,7 @@ var app = new Vue({
295 center: true 308 center: true
296 }).then(function () {}).catch(function () {}); 309 }).then(function () {}).catch(function () {});
297 } else if (command === 'logout') { 310 } else if (command === 'logout') {
298 superagent.post('/api/logout').query({ access_token: localStorage.accessToken }).end(function (error) { 311 logout();
299 if (error) console.error(error);
300
301 that.session.valid = false;
302
303 delete localStorage.accessToken;
304 });
305 } 312 }
306 }, 313 },
307 onDownload: function (entry) { 314 onDownload: function (entry) {