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

Using PowResetPassword & PowEmailConfirmation in an API? #307

Closed
mreishus opened this issue Oct 21, 2019 · 5 comments
Closed

Using PowResetPassword & PowEmailConfirmation in an API? #307

mreishus opened this issue Oct 21, 2019 · 5 comments

Comments

@mreishus
Copy link
Contributor

Is this possible / easy? Any hints on how to get started? I was thinking of making a throwaway project, turning on PowResetPassword PowEmailConfirmation for the web api, using my browser tools to watch the requests being made, then re implementing them in the API. I also might have to copy/modify the default controllers for these.

@danschultzer
Copy link
Collaborator

Yes, but the implementation depends on the API requirements. I would recommend you to follow the API guide first: https://hexdocs.pm/pow/1.0.13/api.html#content

This should give you understanding of what is required to get Pow working in an API. You'll have to build your own controllers, but you can leverage the plug methods. Both PowResetPassword and PowEmailConfirmation has their plug methods documented.

I also recommend that you dig into the custom controllers guide to see how extensions are dealt with. This is where the main difference will be from the default behavior in Pow and how API will handle authentication and registration.

It might be good to have as a guide on https://powauth.com/guides/ so please post any code you work out from this so it can help others 🚀

@mreishus
Copy link
Contributor Author

Ok, giving it a shot, I'll share what I find

@mreishus
Copy link
Contributor Author

I was able to get a very basic PowEmailConfirmation setup working. I documented what I did here: https://github.com/mreishus/notebook-pub/blob/master/programming/phoenix/pow/adding-email-confirmation-to-an-api.md

@mreishus
Copy link
Contributor Author

Here's my guide for PowResetPassword.
https://github.com/mreishus/notebook-pub/blob/master/programming/phoenix/pow/adding-reset-password-to-an-api.md

I probably won't be touching the other two plugins (Invite or Persistent). Not sure that Persistent even makes sense with an API.

@danschultzer
Copy link
Collaborator

This is great, thanks! I'm moving the discussion over to pow-auth/pow_site#14 😄

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

No branches or pull requests

2 participants