From 62aca02aab25804ca4941e3364f2050053eb8999 Mon Sep 17 00:00:00 2001 From: Bui Date: Fri, 13 Mar 2020 03:19:26 +0000 Subject: [PATCH] bugfixes --- app.py | 3 ++- public/src/js/loader.js | 2 +- public/src/js/scorestorage.js | 13 ++++++++++--- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/app.py b/app.py index 569631f..781819d 100644 --- a/app.py +++ b/app.py @@ -25,6 +25,7 @@ except FileNotFoundError: fp.close() app.config['SESSION_TYPE'] = 'redis' +app.config['SESSION_COOKIE_HTTPONLY'] = False app.cache = Cache(app, config={'CACHE_TYPE': 'redis'}) sess = Session() sess.init_app(app) @@ -354,7 +355,7 @@ def route_api_scores_get(): }) user = db.users.find_one({'username': username}) - return jsonify({'scores': scores, 'username': user['username'], 'display_name': user['display_name']}) + return jsonify({'status': 'ok', 'scores': scores, 'username': user['username'], 'display_name': user['display_name']}) def make_preview(song_id, song_type, preview): diff --git a/public/src/js/loader.js b/public/src/js/loader.js index 30c1bd0..ac4e279 100644 --- a/public/src/js/loader.js +++ b/public/src/js/loader.js @@ -157,7 +157,7 @@ class Loader{ })) if(gameConfig._accounts){ - var token = Cookies.get("token") + var token = Cookies.get("session") if(token){ this.addPromise(this.ajax("/api/scores/get").then(response => { response = JSON.parse(response) diff --git a/public/src/js/scorestorage.js b/public/src/js/scorestorage.js index 55dfe02..330a639 100644 --- a/public/src/js/scorestorage.js +++ b/public/src/js/scorestorage.js @@ -51,13 +51,20 @@ class ScoreStorage{ } } } + prepareScores(scores){ + var output = [] + for (var k in scores) { + songs.push({'hash': k, 'score': scores[k]}) + } + return output + } save(localOnly){ for(var hash in this.scores){ this.writeString(hash) } this.write() return this.sendToServer({ - scores: this.scoreStrings, + scores: this.prepareScores(this.scoreStrings), is_import: true }) } @@ -163,7 +170,7 @@ class ScoreStorage{ } this.write() this.sendToServer({ - scores: this.scoreStrings, + scores: this.prepareScores(this.scoreStrings), is_import: true }) } @@ -181,7 +188,7 @@ class ScoreStorage{ account.loggedIn = false delete account.username delete account.displayName - Cookies.remove("token") + Cookies.remove("session") this.load() pageEvents.send("logout") return Promise.reject()