Skip to content

Commit

Permalink
Remove appUserId from storage if the user has a userId (#591)
Browse files Browse the repository at this point in the history
* Remove appUserId from storage if the user has a userId

* Add tests for handleUserConversationResponse
  • Loading branch information
lemieux committed Sep 5, 2017
1 parent fd537eb commit 9587598
Show file tree
Hide file tree
Showing 2 changed files with 205 additions and 147 deletions.
9 changes: 8 additions & 1 deletion src/frame/js/actions/conversation.js
Expand Up @@ -525,7 +525,14 @@ export function handleUserConversationResponse({appUser, conversation, hasPrevio
actions.push(setConfig(key, settings[key]));
}

storage.setItem(`${appId}.appUserId`, appUser._id);
if (appUser.userId) {
// if the user is identified using a userId,
// there's no need to persist or leave the appUserId
// in storage since it's useless without a jwt
storage.removeItem(`${appId}.appUserId`);
} else {
storage.setItem(`${appId}.appUserId`, appUser._id);
}

if (sessionToken) {
storage.setItem(`${appId}.sessionToken`, sessionToken);
Expand Down

0 comments on commit 9587598

Please sign in to comment.