Improve login

This commit is contained in:
Christoph Hagen 2022-10-13 09:13:36 +02:00
parent 41560fa87c
commit 784bf35c6a
2 changed files with 11 additions and 5 deletions

View File

@ -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() {

View File

@ -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";
}