Skip to content

Commit 413d9d0

Browse files
committed
fix: error for empty dashboard and private dashboard id in cookie
Before the `isGuestDashboardKey()` utility function threw an error, in the `useDasboardKeyProvider()` composable. Only when the url was `/dashboard` (no dashboard key) and the `bc-validator-dashboard-key` cookie value was a number (e.g. private dashboards). Trying to use startsWith() on a number remained undetected since the `useBcCookie() composable` used `string` as a default type value.
1 parent d939acd commit 413d9d0

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

frontend/composables/useBcCookie.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ type OptionsUseCookie<T> = CookieOptions<T> & {
2121
* This allows us to have autocompletion for the cookie names.
2222
*
2323
*/
24-
export const useBcCookie = <T = string | undefined>(
24+
export const useBcCookie = <T = unknown>(
2525
name: CookieName,
2626
options?: OptionsUseCookie<T>,
2727
) => {

frontend/composables/useDashboardKeyProvider.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,8 @@ export function useDashboardKeyProvider(
6565
// only use the dashboard cookie key as default if you are not logged in and it's not private
6666
if (
6767
!isLoggedIn.value
68-
&& isGuestDashboardKey(dashboardKeyCookie.value)
69-
&& !isSharedDashboardKey(dashboardKeyCookie.value)
68+
&& isGuestDashboardKey(`${dashboardKeyCookie.value}`)
69+
&& !isSharedDashboardKey(`${dashboardKeyCookie.value}`)
7070
) {
7171
setDashboardKey(`${dashboardKeyCookie.value}`)
7272
}
@@ -135,7 +135,7 @@ export function useDashboardKeyProvider(
135135
oldValue
136136
&& !newValue
137137
&& dashboardKeyCookie.value
138-
&& !isNaN(parseInt(dashboardKeyCookie.value))
138+
&& !isNaN(parseInt(`${dashboardKeyCookie.value}`))
139139
) {
140140
setDashboardKey('')
141141
}

frontend/stores/dashboard/useUserDashboardStore.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ export const useUserDashboardStore = defineStore('user_dashboards_store', () =>
2929
return dashboardCookie.value as any as UserDashboardsData
3030
}
3131
else {
32-
return JSON.parse(dashboardCookie.value)
32+
return JSON.parse(`${dashboardCookie.value}`)
3333
}
3434
}
3535
})

0 commit comments

Comments
 (0)