Save the session in the AuthClient#33
Closed
martin-g wants to merge 1 commit into
Closed
Conversation
Signed-off-by: Martin Tzvetanov Grigorov <mgrigorov@apache.org>
Author
|
I didn't do the changes in |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What kind of change does this PR introduce?
New feature (idea for improvement):
The
Sessionreturned by thelogin_***methods is stored in the AuthClient itself.This way the AuthClient could use the correct
access_tokeninget_user(),get_settings(), etc. without requiring the developer to provide the access token as a method parameter. Same for therefresh_tokeninrefresh_session()method.What is the current behavior?
The
Sessionis returned from thelogin_***()methods and it is responsibility of the user application to pass the correct token where needed.What is the new behavior?
The
Sessionis still returned by thelogin_**()methods and the user application may use it if needed.But the AuthClient itself also keeps a handle to the last authenticated session and use its tokens appropriately where needed.
Additional context
My idea is inspired by xylex-group/supabase_rs#42
There I want to authenticate the user via
supabase.auth().login_***()and start doingsupabase.insert()/update()/select()/delete(). By keeping a reference to theSessionthe insert/update/... operations could use the correct bearer depending on whether the user is authenticated or not:https://github.com/floris-xlx/supabase_rs/pull/42/files#diff-b1a35a68f14e696205874893c07fd24fdb88882b47c23cc0e0c80a30c7d53759R432-R437