fix discord login errors

This commit is contained in:
Alberto Xamin 2023-02-09 10:52:05 +00:00
parent 84d4dcd98e
commit 8d06cc2a77
2 changed files with 5 additions and 1 deletions

View File

@ -138,7 +138,7 @@ def set_username(sid, username):
ses = sio.get_session(sid) ses = sio.get_session(sid)
if not isinstance(ses, Player): if not isinstance(ses, Player):
dt = username["discord_token"] if 'discord_token' in username else None dt = username["discord_token"] if 'discord_token' in username else None
sio.save_session(sid, Player(username["name"], sid, discord_token=dt)) sio.save_session(sid, Player(username.get('name', 'player'), sid, discord_token=dt))
print(f'{sid} is now {username}') print(f'{sid} is now {username}')
advertise_lobbies() advertise_lobbies()
elif ses.game is None or not ses.game.started: elif ses.game is None or not ses.game.started:

View File

@ -169,6 +169,10 @@ export default {
'Authorization': 'Bearer ' + localStorage.getItem('discord_token') 'Authorization': 'Bearer ' + localStorage.getItem('discord_token')
} }
}) })
.then((res) => {
if (res.status !== 200) throw new Error(res.status)
return res
})
.then(response => response.json()) .then(response => response.json())
.then(data => { .then(data => {
console.log(data) console.log(data)