Rank 2: Process
Only one more question. When i have session and i send it to server, is there any way to use that session to authorizate the user? Not by creating JWT.
Votes
1
Replies
24
Participants
Unknown
Messages
25
Rank 2: Process
Only one more question. When i have session and i send it to server, is there any way to use that session to authorizate the user? Not by creating JWT.
Yes, for that you'll need to do all the login process with a cookie jar.
Check this example for a demo.
Btw
What is your use case?
Rank 2: Process
I am sorry for missunderstanding. But this still works by creating JWT on server-side
You're correct in that example you can see 2 things
Rank 2: Process
i log in by email on server-side then session saves in cookies on client. Then client sends cookies in headers to server (i am using SSR-sveltekit) and then server should authorizate the user
Okay, that should work
Something like this?
Rank 2: Process
yes exactly, then server sends fallback cookie to user and user back to server during fetch
Good
So store that cookie some whare and you can reuse it to auth the user in subsequent requests
And you won't need the JWT
Rank 2: Process
yes but how will i be able to act like user on server-side without JWT (only with session) ?
You were creating JWT in your example
Yes, but that is only because in that example he wanted to have JWT.
It's like this 👇
When you want to access Appwrite resources as a user you'll need to be authenticate, you can do it in one of two ways
X-Fallback-Cookies header like you can see here, you're actually being authenticate as the user. meaning, you can do any REST action on behalf of that user.Is this make sense?
Rank 2: Process
Yes i am sorry. But can i set cookies on your appwrite SDK?
Rank 2: Process
Thank you very much. This is what i am doing for REST API
What you mean? using the Web SDK?
Rank 2: Process
no no server node.js SDK
Nope,
The server SDK supports only the Server side endpoints, so you'll have to use the either the client-side Web sdk or the pure REST like you're already doing.
Also, Check the
Almost-ssr by Meldiron which uses the SDK to login from the server side.
Rank 2: Process
Yes, thank you very much. Maybe i will be looking for another sollutions
Rank 2: Process
Yes thank you, i know i used it
Rank 2: Process
Thank you very much for all your help 
