Export filterDefaultIdTokenClaims and update beforeSessionSaved docs #2119
+28
−9
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
📋 Changes
We have the following code here:
What we can see here is that if the user does not pass a
beforeSessionSaved
handler, thesession.user
is set to a filtered list of claims to only contain the default tokens.However, when a
beforeSessionSaved
handler is passed, the claims aren't filtered, and thesession.user
object passed tothis.beforeSessionSaved
has a non-filtered list of claims.This means, that the following code would include all claims:
However, this isn't clear from the docs. Additionally, if a user wants to only include a single claim, they currently need to ensure they provide all the default claims manually:
This is way to complicated and not the kind of experience we want. Therefore this PR exports the
filterClaims
(and renames it tofilterDefaultIdTokenClaims
, so it can be used in custombeforeSessionSaved
handlers accordingly.📎 References
🎯 Testing