aaronrenner / phx_gen_auth

An authentication system generator for Phoenix 1.5 applications.
774 stars 56 forks source link

Why the incongruity with official Contexts docs (no Credential schema)? #44

Closed peaceful-james closed 4 years ago

peaceful-james commented 4 years ago

When I use this generator, I get a User model in an Accounts context, with an email field on it. In the hexdocs for Contexts (https://hexdocs.pm/phoenix/contexts.html), it is recommended to put email on a separate Credential schema. I am wondering - is there a good reason not to use the Credential approach? Thanks for any feedback.

josevalim commented 4 years ago

There is no correct way to design a system. Phoenix contexts used credentials for its own reasons and also for teaching purposes, but it is just one possibility, not a recommendation. Other libraries like Pow use different approaches.

peaceful-james commented 4 years ago

Thanks for the quick feedback! If Jose says it's OK both ways, I feel better. :+1:

josevalim commented 4 years ago

Haha. :) I did consider having a credential like approach too - but it is a lot more complexity that may not be necessary in many cases. I also think it is probably better to have one e-mail being your primary email (therefore in the users table) and the others can be in a separate table and used for secondary purposes.