riverrun / phauxth

Not actively maintained - Authentication library for Phoenix, and other Plug-based, web applications
409 stars 20 forks source link

Use `context_app` config when determining the `user_context` #76

Closed QuinnWilton closed 5 years ago

QuinnWilton commented 6 years ago

I have an umbrella application with my business logic in an app named AppExample, and my web application in an app named AppExampleWeb. This means that my user_context is App.Accounts, instead of AppWeb.Accounts, the default that Phauxth uses. This is fixable by overwriting the user_context config for Phauxth, but Phoenix actually already has a configuration field that specifies what application your contexts live in, for the purpose of using generators:

config :app_example_web,
  generators: [context_app: :app_example]

Instead of defaulting the user_context to the current application, you could instead see whether the generators are configured in such a manner.

riverrun commented 5 years ago

Thanks for raising the issue. Could you send me a link so that I can find out more info about the Phoenix configuration field for generators?

QuinnWilton commented 5 years ago

This is the best reference I can find :)

https://github.com/phoenixframework/phoenix/blob/v1.3.4/lib/mix/tasks/phx.gen.html.ex#L32

riverrun commented 5 years ago

In version 2.0, the function to work out the user_context module has been removed, so you will need to set the user_context in the config anyway.

As you are using an umbrella app, issue #83 might be of some interest to you.