-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix/use fresh tokens #1627
Fix/use fresh tokens #1627
Conversation
…hToken to be deparacated
Co-authored-by: Peter Pistorius <peter.pistorius@gmail.com>
Update: repro'd the test issue https://s.tape.sh/WIyxZqox |
…h-tokens * 'main' of github.com:redwoodjs/redwood: Move whatwg-fetch from devDep to dep Adds mockCurrentUser() to api-side jest v0.22.1 v0.22.0 Revert "Configure ApolloProvider to always use fresh tokens (redwoodjs#1609)" (redwoodjs#1611) Configure ApolloProvider to always use fresh tokens (redwoodjs#1609) Ignore *.scenarios.* files. (redwoodjs#1607) upgrade prisma v2.12.1 (redwoodjs#1604) Test Scenarios (redwoodjs#1465) Use relative path to config stories location (redwoodjs#1509)
…fix/use-fresh-tokens * 'fix/use-fresh-tokens' of github.com:dac09/redwood:
a1e9711
to
7307ad3
Compare
Added extra checks, before calling getToken. e2e tests now pass https://s.tape.sh/UOJM6MYf ✅ |
Thanks for giving this another go @dac09 🚀 Release NotesInclude Deprecation Warning:
|
@peterp handing over to you for review + merge |
const { getToken, type: authProviderType, isAuthenticated } = useAuth() | ||
|
||
const withToken = setContext(async () => { | ||
if (isAuthenticated && getToken) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a case when getToken
would be falsy?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was causing the failure in the e2e test. Its falsy when you're not logged in - wasn't sure if there's any other case where its falsy apart from the first render of the auth provider.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
getToken is falsey? But surely that shouldn't be the case since the function is provided via the provider? Maybe one of the "fake implementations" doesn't follow the providers spec.
@peterp bumping this, responded to your comments :) |
Co-authored-by: Peter Pistorius <peter.pistorius@gmail.com>
Creating this PR again repeat of #1609.
New tasks:
getToken
is not found error for apps without Auth