aaronrenner / phx_gen_auth

An authentication system generator for Phoenix 1.5 applications.
772 stars 55 forks source link

Add a --context-app for umbrella with a dedicated database app #128

Closed Aridjar closed 3 years ago

Aridjar commented 3 years ago

Hello.

First of all, thanks for the lib! I hesitated to open an issue directly in the phoenix repo, but as it doesn't seem like both and neither a feature nor a bug, I didn't know where to put it, so here it is. Sorry if it misplaced.

When creating an umbrella project with multiple app depending of the same Database, I use a vanilla app with Ecto as a base app for the database through the option: --context-app.

mix phx.gen.schema Users.User users email:string password:string --context-app database

This allow each app to depend only from the specific DB instead of another one, as it place the context in a shared app.

Unfortunately, when running the phx.gen.auth cli, there is no option to indicate the place of the Repo module, forcing to have a Repo is the app where we want the auth.

Edit 2021/09/07: After some research, I found the possibility to do so by using the following config:

config :my_app_web, :generators,
  context_app: :my_app

Though it isn't documented.

The code modification associated with the add of the --context-app is 1 line in the @switches in the \lib\mix\tasks\phx.gen.auth.ex:84 file.

  @switches [
    web: :string,
    binary_id: :boolean,
    hashing_lib: :string,
    table: :string,
    merge_with_existing_context: :boolean,
    prefix: :string,
    context_app: :string
  ]

Unfortunately, and though the test was working fine alone, I couldn't manage to make it work in bulk as the mix.exs was remove from the folder due to another test.

aaronrenner commented 3 years ago

@Aridjar Thanks for trying out this library! Now that phx.gen.auth has been merged into phoenix 1.6, I'm going to archive this repo. Would you mind opening this issue over on the phoenix repo?

Thanks!