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
Question - JWT Token Expiring Error When Querying Supabase Directly #39
Comments
Hello, thanks for your kind words :) The best way to get Example : supa-fly-stack/app/routes/rls/notes.tsx Lines 11 to 15 in 868edd7
That's for For supa-fly-stack/app/routes/rls/notes/new.tsx Lines 59 to 75 in 868edd7
That's because,
Starting point : https://github.com/rphlmr/supa-fly-stack/blob/main/app/core/auth/guards/require-auth-session.server.ts supa-fly-stack/app/core/auth/mutations/refresh-auth-session.server.ts Lines 27 to 68 in d0fa056
Let me know if it solves your issue or if I'm totally wrong ;) |
A question on this: isn't it enough to use the requireAuthSession in the loader? Why do you actually need to do this in your action? If you need the userId, you could have a method that can retrieve it from the request and simply throw if it's not available? |
I think he is just ensuring that you have a valid token before you attempt
to take some action on the database. That I what I got out of his comment
and reading through the code.
On Thu, Aug 4, 2022 at 7:28 PM Michael Sevestre ***@***.***> wrote:
A question on this: isn't it enough to use the requireAuthSession in the
loader? Why do you actually need to do this in your action?
—
Reply to this email directly, view it on GitHub
<#39 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAEAFGNXLTEJFKZ4KIFWD53VXRGZ7ANCNFSM55TFOOVQ>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
--
…--
Aaron K. Saunders
CEO Clearly Innovative Inc
***@***.***
www.clearlyinnovative.com
This email message and any attachment(s) are for the sole use of the
intended recipient(s) and may contain proprietary and/or confidential
information which may be privileged or otherwise protected from disclosure.
Any unauthorized review, use, disclosure or distribution is prohibited. If
you are not the intended recipient(s), please contact the sender by reply
email and destroy the original message and any copies of the message as
well as any attachment(s) to the original message.
|
Yes but wouldn't the loader kick in before? |
Hi, loader and action have to be treated independently since anything can post directly on your action without triggering loader (like a fetcher from useFetcher, external fetch, ...). |
Sure. But in the case of the notes, you could throw if the authSession was invalid no? I understand what the aim is but I am wondering if this is required |
I'll post a code snippet tomorrow |
ok so this is what I meant: what about having two sets of methods: for LoaderWe use requireAuthSession. This ensures that we actually have a session and that we can refresh the session if it is expiring etc for Actions (POST, PUT,etc...)We use something relying on something like this
Problem with this: This does not refresh the session on action. But with your latest PR, where the token is refreshed a few minutes before expiring, this should prevent issues with token expiring while the action is performed. This way, the action code is much leaner and you do not have to deal with sessions etc in in your action code. |
Hey @rphlmr |
Feel free to reopen as I made some changes since the day you open this issue 😬 |
First off thank you for the application, I am using it as a reference for a solution I am creating.
I am running into a problem where I am getting an error saying
when doing queries in my application. I am confused because the call to
getAuthSession
is returning a valid session but when get the supabase clientand make a database call, it errors out
The text was updated successfully, but these errors were encountered: