Uh oh!
There was an error while loading. Please reload this page.
[SID-1762] React: default to 'localStorage' storage when anonymous users enabled - #283
[SID-1762] React: default to 'localStorage' storage when anonymous users enabled#283jake-slashid wants to merge 2 commits into
Conversation
ikovic
commented
Jun 20, 2024
@jake-slashid I like the runtime change, but I feel it would still be well worth it to also prevent this during static checks - having a union type discriminated by the |
| const STORAGE_TOKEN_KEY = "@slashid/USER_TOKEN"; | ||
| const createStorage = (storageType: StorageOption) => { | ||
| const createStorage = (storageType: StorageOption, options: { anonymousUsersEnabled: boolean }) => { |
There was a problem hiding this comment.
IMO this must be handled one level above, as the SlashID context provider is the owner of this business logic.
ikovic
commented
Jun 20, 2024
As far as testing goes, it seems as there is a chunk of business logic in the IMO there is enough logic here that it could be wrapped in a domain function like The function could be exported individually so we could test it easily with a unit test, no mocking needed. What do you think? |
Description
YouTrack issue
Issue:
If anonymous users is turned on but storage is left default, it will be
memorywhich means the anonymous users is lost each time the page refreshes.Fix:
localStorageby default if anonymous users enabledmemorywhile anonymous users enabled