feat: improved insecure getSession()
warning
#1024
Open
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.
Previously when attempting to use
getSession()
from insecure storage such as cookies in SSR on the server, a disruptive warning was logged.It's been a long while and most developers should already be conditioned that general use of
getSession()
for authorization on the server should not be used. There are, however, some valid use cases forgetSession()
that used to log a warning but now won't:Does (any) session exist or not?
Most applications want to redirect the user to a login page if there's no session and probably are not interested in validating that the session is actually OK. This can be achieved with the following sample code:
Simple boolean user check?
Note that this does not answer what user is there.
Just access an up-to-date access token to send to a private API?