Is there a way to use Phx Gen Auth without Emails?

We are making an app that doesn’t use emails.

Pow has a way to change the user_id_field to accommodate non-emails.

How can we configure Phx Gen Auth to use nickname or some other string instead email as User ID?

1 Like

There is no such configuration option, but you can tweak the generated code as you wish. For example, you can rename the email field to nickname, in all the generated files. Some things from the top of my head, that you’d have to look out for:

  • emails use the ci_text extension (case insensitive), which might not be useful for nicknames.
  • there is a lot of management around confirming accounts and changing passwords, which hinges on sending emails. You’ll have to remove this, and think about how your account management looks like. You’ll have to do the work, no silver bullet there if you’re not following the standard path (no worries, almost everybody tweaks to their situation).

If you only want session management (no user and credential management), consider using the guardian library. But then you’d still need to manage your users/accounts somehow, or hook into other social identity providers with OAuth (very doable).

Main message: don’t be afraid to change the generated code to your needs, after studying it (it’s no rocket science, just very well thought out standard flow).

If Pow is in your toolbox allready, why not keep using it? It’s still well maintained and supported afaik (never used it though, just know what it’s used for).

4 Likes