From c779d475373e88dbd0ffa6352f77ab88cf729667 Mon Sep 17 00:00:00 2001 From: Yann Stepienik Date: Sat, 7 Oct 2023 14:37:40 +0100 Subject: [PATCH] [release] v0.10.0-unstable30 --- client/src/utils/hooks.js | 20 ++++++++++++++------ package.json | 2 +- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/client/src/utils/hooks.js b/client/src/utils/hooks.js index 764351c..1cd4994 100644 --- a/client/src/utils/hooks.js +++ b/client/src/utils/hooks.js @@ -3,22 +3,30 @@ import { useCookies } from 'react-cookie'; import { logout } from '../api/authentication'; function useClientInfos() { - const [cookies] = useCookies(['client-infos']); + const [cookies] = useCookies(['client-infos', 'jwttoken']); + + if(cookies['jwttoken'] === undefined) { + // probably the demo or new install + return { + nickname: "", + role: "2" + } + } let clientInfos = null; try { // Try to parse the cookie into a JavaScript object clientInfos = cookies['client-infos'].split(','); + + return { + nickname: clientInfos[0], + role: clientInfos[1] + }; } catch (error) { console.error('Error parsing client-infos cookie:', error); logout(); } - - return { - nickname: clientInfos[0], - role: clientInfos[1] - }; } export { diff --git a/package.json b/package.json index e90d3a4..e740ca8 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "cosmos-server", - "version": "0.10.0-unstable29", + "version": "0.10.0-unstable30", "description": "", "main": "test-server.js", "bugs": {