From c9eae00c8c91ffbebb63e694cbc6af21f78afc9a Mon Sep 17 00:00:00 2001 From: neobooru <50623835+neobooru@users.noreply.github.com> Date: Thu, 26 Sep 2019 01:41:53 +0200 Subject: [PATCH] client/login: always store login cookie as 'auth' Fixes #268 --- client/js/api.js | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/client/js/api.js b/client/js/api.js index c8e571c5..07ec5ec9 100644 --- a/client/js/api.js +++ b/client/js/api.js @@ -9,18 +9,6 @@ const uri = require('./util/uri.js'); let fileTokens = {}; let remoteConfig = null; -function getCookieName() { - const bases = document.getElementsByTagName('base'); - if (bases.length) { - let baseHref = bases[0].href; - baseHref = baseHref.replace('/', ''); - return 'szuru-' + baseHref; - } else { - return 'szuru'; - } -} -const cookieName = getCookieName(); - class Api extends events.EventTarget { constructor() { super(); @@ -138,7 +126,7 @@ class Api extends events.EventTarget { } loginFromCookies() { - const auth = cookies.getJSON(cookieName); + const auth = cookies.getJSON('auth'); return auth && auth.user && auth.token ? this.loginWithToken(auth.user, auth.token, true) : Promise.resolve(); @@ -181,7 +169,7 @@ class Api extends events.EventTarget { this.post('/user-token/' + userName, userTokenRequest) .then(response => { cookies.set( - cookieName, + 'auth', {'user': userName, 'token': response.token}, options); this.userName = userName;