feat: login by passing API token in URL #hash #1875
Draft
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.
This adds the ability to set the URL hash to
#authToken=<your-api-key>
and use it to authenticate to the API.It adds a
/user/meta
route to return theissuer
andpublicAddress
, which we were previously getting fromgetMagic().user.getMetadata()
.The "is logged in" check in
_app.js
was previously usinggetMetadata()
to set theuser
object that gets passed through toUserContext
. Since we can no longer assume that all logged in users will have a valid magic link session, I had to add a server route to return similar data (issuer
andpublicAddress
).Stores the token from the fragment in localStorage, so we can clear the fragment and keep accessing the token. Maybe sessionStorage is more appropriate? I forget when to use which, lol.
This probably needs some cleanup, and it's branched off of #1864, so it's a draft for now.
@redaphid will you play with this next week? I probably won't have time to work on it, but I can answer any questions you might have.
To use it with the test user in the local development env, follow this link while the dev server is running from this branch (assuming it's on the default port).