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

Generators: Add auth generator for Magic.Link #623

Closed
cannikin opened this issue May 29, 2020 · 16 comments · Fixed by #644
Closed

Generators: Add auth generator for Magic.Link #623

cannikin opened this issue May 29, 2020 · 16 comments · Fixed by #644

Comments

@cannikin
Copy link
Member

Now that support for Magic.Link has been added to @redwoodjs/auth as of 0.8.0 we can add a generator that helps setup and configure this automatically.

Take a look at the existing providers and the README to see how to add Magic.Link support. If you need additional hooks to insert generated code into you will need to modify the auth generator itself.

@gizmoGremlin
Copy link
Contributor

Hi, I'd like to work on this if no else has started. I'm new here, I've just finished the tutoral and browsed the framework code. I'd also like to say, I really like the vision of this project. Cheers

@thedavidprice
Copy link
Contributor

Great! I'll assign this one to you. Definitely look to @cannikin as point for help along the way with the generators. For any Auth specific instructions, @peterp created the original package and @burnsy did the provider work on Magic.Link.

Oh, and I'm the annoying guy who will show up at the very end to ask if the PR includes updated documentation 😉 (Everyone has their role, right?)

Looking forward to this one 🚀

@gizmoGremlin
Copy link
Contributor

Ok great!, Thanks for the detailed reply @thedavidprice

@BurnedChris
Copy link
Contributor

I don't mind giving a hand if needed! 👍

@gizmoGremlin
Copy link
Contributor

gizmoGremlin commented Jun 1, 2020

@cannikin or @burnsy I'm having trouble generating the correct import statement for magic.link. It needs to create {} around the inport i.e. .. import { Magic } from 'magic-sdk'... right now it does not, it generates import Magic from 'magic-sdk.
I see that for the auth0, brackets were used in the import statement but not in the case of netlify-identity.
Any quick tips, maybe i'm missing something obvious , before I dive into the generator code?

@cannikin
Copy link
Member Author

cannikin commented Jun 1, 2020

Did you try doing:

imports: [{ import: '{ Magic }', from: 'magic-sdk' }]

The code that writes out the import does:

const importStatements = imports.map((imp) => {
  return `import ${imp.import} from '${imp.from}'`
})

So it should include the {} as long as they're inside that first string.

@gizmoGremlin
Copy link
Contributor

@cannikin no I didn't, because the auth0 provider, which generates brackets, isn't Implemented that way . I'm wondering how it was accomplished in that case. Anyway,I will try your suggestion thanks!
Secondly, should I add any generated code to the back-end. e.g. https://redwoodjs.com/docs/authentication#magic-links
or would that be a seperate pull request

@cannikin
Copy link
Member Author

cannikin commented Jun 1, 2020

That might be a bug—if auth0 requires { } around the import then that generator should definitely have them!

When you refer to the back-end are you talking about the code in api/src/lib/auth.js? getCurrentUser is meant to be specific to your own application's idea of what a user is, so I we can't pre-fill that with anything other than the default—just returning what the auth provider provides. It's up to you to figure out what you need from that to look up and return a user from your data store.

@gizmoGremlin
Copy link
Contributor

@cannikin Ok thanks, that makes sense.
@thedavidprice Where/How do I update the docs. Is it just changing the readme files in the monorepo?

@cannikin
Copy link
Member Author

cannikin commented Jun 1, 2020

Opened a PR to fix that auth0 import! #640

@thedavidprice
Copy link
Contributor

There are a few things in motion with docs as we are in a bit of a re-org. So most of the docs are or will be in this /docs folder on the .com repo.

But you are correct --> currently the Auth doc is the README in the auth package. For the generator, it looks like you'll primarily need to update the "Installation" section both for available providers and the Manual Install of Magic.Link (assuming a package would need to be added).

AND you'll also need to add the provider option to this section of the CLI Docs. This Doc correlates with the information you should see when you run yarn rw g auth --help.

Lots of bits and pieces, but is it making sense?

Thanks again!

@gizmoGremlin
Copy link
Contributor

@thedavidprice the second link you left is broken. Can you give a path, I can't seem to find it

@thedavidprice
Copy link
Contributor

thedavidprice commented Jun 2, 2020

@gizmoGremlin
Copy link
Contributor

@thedavidprice I'm unclear as how to edit the docs in the redwood.js repo within this pull request.
Isn't the redwoodjs.com a seperate repository from the redwood repository? Can I update redwood.js/blob/master/docs in a seperate pull request?
I'm a little new to this
Thanks in advance

@thedavidprice
Copy link
Contributor

Ah, great question! And you may feel new, but trust me, we're all relatively new and figuring things out as we go. Together. So welcome to the party 🎉

Yes, you'll need to handle that separately on the redwoodjs.com repo. That doc was created by @jtoar who I'm sure would be happy to help if/when needed.

Overall we're just trying to get better at including doc creation/update with PRs. But sometimes that might simply mean creating an Issue with a plan and making a handoff by asking for help. Whatever steps you're able to take, just reference the other Issues or PRs via links to the main Issue or PR -- that way we can allow follow the trail, connect dots, and quickly see what next steps might need to be completed.

@gizmoGremlin
Copy link
Contributor

@thedavidprice Ok, Thanks again. I'll do that.

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

Successfully merging a pull request may close this issue.

4 participants