Log in with username and password in Phoenix app

Does ash auth Phoenix have a declarative way to log in with username instead of email address? I changed my resources but it looks like I need to change something else.
7 Replies
ZachDaniel
ZachDaniel2y ago
I think there is a DSL option to specify this
ZachDaniel
ZachDaniel2y ago
That top guide shows identity_field :email
Terris
TerrisOP2y ago
Using " identity_field(:username)" does what I want. However, is there a way to require email address and username in the registration form? I tried
register_action_accept([:username, :email])
register_action_accept([:username, :email])
But it will prompt for one or the other.
ZachDaniel
ZachDaniel2y ago
Yeah, IIRC the autogenerated UI won’t add additional fields. The general idea is to make it a two step process, like redirect them to a username screen. PRs welcome WRT adding additional fields automatically
dblack
dblack2y ago
This article shows how to replace the sign in and register routes with your own custom liveviews, which is probably a great way to go to add your custom fields during registration: https://alembic.com.au/blog/customising-ash-authentication-with-phoenix-liveview
Alembic
Customising Ash Authentication with Phoenix LiveView
A Sydney-based Software Development Consultancy building cutting edge Web and API experiences with Elixir, TypeScript, GraphQL and React.
Terris
TerrisOP2y ago
Thank you! I have been through that article. Very well written. I’d love to be able to give you some code back that would have a flow that say would verify the email address first and then ask for a username. My liveview and elixir skills are still pretty bad. Currently toying with idea that email address isn’t unique. Only usernames in a tenant are unique And why is email special? It could be a phone number.

Did you find this page helpful?