Skip to content
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

feat: login by passing API token in URL #hash #1875

Draft
wants to merge 2 commits into
base: chore/refactor-frontend-api-methods
Choose a base branch
from

Conversation

yusefnapora
Copy link
Contributor

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 the issuer and publicAddress, which we were previously getting from getMagic().user.getMetadata().

The "is logged in" check in _app.js was previously using getMetadata() to set the user object that gets passed through to UserContext. 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 and publicAddress).

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).

@cloudflare-workers-and-pages
Copy link

Deploying with  Cloudflare Pages  Cloudflare Pages

Latest commit: 8622dd1
Status: ✅  Deploy successful!
Preview URL: https://f699041c.nft-storage-1at.pages.dev

View logs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant