Set the user's ID in LocalStorage

This commit is contained in:
Oliver-Akins 2020-10-21 20:49:27 -06:00
parent 953ea01673
commit 956c28ed39
3 changed files with 9 additions and 0 deletions

View file

@ -1,8 +1,15 @@
This document details the data stored in localStorage and sessionStorage of the browser. This document details the data stored in localStorage and sessionStorage of the browser.
# Session Storage
| Key | Data Type | Description | Key | Data Type | Description
| --------- | --------- | ------------- | --------- | --------- | -------------
| game-code | String | The current game code the player is in, if this is not set, then they are not in a game | game-code | String | The current game code the player is in, if this is not set, then they are not in a game
| is-host | Boolean | If the player is the host of the game or not. | is-host | Boolean | If the player is the host of the game or not.
| user-name | String | The name of the user in the game. | user-name | String | The name of the user in the game.
# Local Storage
| Key | Data Type | Description
| --------- | --------- | -------------
| user-id | UUID | The user's ID as assigned by the server. This is used to let players re-join games if/when they need to refresh for whatever reason. This is decided by the server and is sent back to the client to ensure the ID is unique across the system. | user-id | UUID | The user's ID as assigned by the server. This is used to let players re-join games if/when they need to refresh for whatever reason. This is decided by the server and is sent back to the client to ensure the ID is unique across the system.

View file

@ -66,6 +66,7 @@ export default {
}); });
return; return;
}; };
localStorage.setItem(`user-id`, data.uuid);
sessionStorage.setItem(`user-name`, this.username); sessionStorage.setItem(`user-name`, this.username);
sessionStorage.setItem(`game-code`, this.game_code); sessionStorage.setItem(`game-code`, this.game_code);
sessionStorage.setItem(`is-host`, false); sessionStorage.setItem(`is-host`, false);

View file

@ -42,6 +42,7 @@ export default {
sockets: { sockets: {
HostInformation(data) { HostInformation(data) {
if (data.success) { if (data.success) {
localStorage.setItem(`user-id`, data.uuid)
sessionStorage.setItem(`game-code`, data.game_code); sessionStorage.setItem(`game-code`, data.game_code);
sessionStorage.setItem(`is-host`, true); sessionStorage.setItem(`is-host`, true);
this.$emit(`go-to`, `lobby`); this.$emit(`go-to`, `lobby`);