Commit 996e13b3 by Johannes Zellner

Fix logout situation if token is invalid

1 parent c66d7093
Showing with 16 additions and 9 deletions
(function () {
'use strict';
/* global superagent */
/* global Vue */
/* global $ */
/* global filesize */
// poor man's async
function asyncForEach(items, handler, callback) {
var cur = 0;
......@@ -86,6 +91,16 @@ function refresh() {
loadDirectory(app.path);
}
function logout() {
superagent.post('/api/logout').query({ access_token: localStorage.accessToken }).end(function (error) {
if (error) console.error(error);
app.session.valid = false;
delete localStorage.accessToken;
});
}
function loadDirectory(filePath) {
app.busy = true;
......@@ -278,8 +293,6 @@ var app = new Vue({
});
},
onOptionsMenu: function (command) {
var that = this;
if (command === 'folderListing') {
superagent.put('/api/settings').send({ folderListingEnabled: this.folderListingEnabled }).query({ access_token: localStorage.accessToken }).end(function (error) {
if (error) console.error(error);
......@@ -295,13 +308,7 @@ var app = new Vue({
center: true
}).then(function () {}).catch(function () {});
} else if (command === 'logout') {
superagent.post('/api/logout').query({ access_token: localStorage.accessToken }).end(function (error) {
if (error) console.error(error);
that.session.valid = false;
delete localStorage.accessToken;
});
logout();
}
},
onDownload: function (entry) {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!