Creating Users

Now that things are working smoothly and safely, let’s integrate that new code with our web layer through the public API we expose through the Accounts context. We’ll need to replace Accounts.create_user with a function that performs proper account registration with passwords.

Since our UserController currently calls the Accounts.create_user function, we hope to get by with minimal changes. Our approach works fine but internally we are only using the base User.changeset which doesn’t yet include our password hashing.

At this point, we could change the Accounts.create_user function to use the registration_changeset. Instead, we will explicitly build a new function to manage registration details. We’ll maintain create_user to expose ...

Get Programming Phoenix 1.4 now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.