From 784bf35c6ad3ae0e1cc48c31105e00484dfa3ffb Mon Sep 17 00:00:00 2001 From: Christoph Hagen Date: Thu, 13 Oct 2022 09:13:36 +0200 Subject: [PATCH] Improve login --- Public/login.html | 9 +++++---- Public/login.js | 7 ++++++- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/Public/login.html b/Public/login.html index 17b43ab..bc9563a 100644 --- a/Public/login.html +++ b/Public/login.html @@ -39,15 +39,16 @@ return } performLoginPlayerRequest(username, password) - .then(function(token) { - storePlayerNameAndToken(username, token) - window.location.href = "schafkopf.html"; - }).catch(function(error) { + .catch(function(error) { console.log("Failed to log in") console.log(error) // TODO: Create better error message for user setTextHint(error); }) + .then(function(token) { + storePlayerNameAndToken(username, token); + showTableList(); + }) } function showDebugLogins() { diff --git a/Public/login.js b/Public/login.js index 5e67705..d4da7af 100644 --- a/Public/login.js +++ b/Public/login.js @@ -55,10 +55,15 @@ function loadExistingSession() { resumeSessionRequest(token) .then(function(name) { storePlayerNameAndToken(name, token); - window.location.href = "list.html"; + showTableList(); }).catch(function(error) { // We don't expect a session to resume if the registration page is shown, // and if the token is expired on the login page we just fail quietly. console.log(error); + deleteSessionToken(); }) } + +function showTableList() { + window.location.href = "list.html"; +}