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 the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.