Closed arnimikelsons closed 10 months ago
I believe this error happens when you are changing the controller to use :formats
option. This is will change how Phoenix build the module name, so now it'll expect AafWeb.Pow.SessionHTML
rather than AafWeb.Pow.SessionView
.
You'll need to update the view module name to the new format, or remove the : formats
option if you wish to keep the view module naming.
Easiest approach would likely be to just run mix pow.phoenix.gen.templates
again, generating the new structure, and then move over the templates into the newly generated files.
Let me know if this solves the issue! I should probably add a 1.7 migration note regarding this.
created a new instace with Erlang 25.3.2.4, Elixir 1.14.5-otp-25, phoenix 1.7.7
add {:pow, "~> 1.0.31"} to mix.exs
run mix pow.phoenix.gen.templates
In upgraded existing instance:
mix pow.phoenix.gen.templates
update fields with additional fields that were created
deleted registration_view.ex and session_view.ex under app_web/views/pow
deleted app_web/templates/pow directory
ran mix phx.server and getting
% mix phx.server
Compiling 2 files (.ex)
== Compilation error in file lib/aaf_web/controllers/pow/registration_html.ex == ** (UndefinedFunctionError) function AafWeb.html/0 is undefined or private AafWeb.html() expanding macro: AafWeb.using/1 lib/aaf_web/controllers/pow/registration_html.ex:2: AafWeb.Pow.RegistrationHTML (module) (elixir 1.14.5) expanding macro: Kernel.use/2 lib/aaf_web/controllers/pow/registration_html.ex:2: AafWeb.Pow.RegistrationHTML (module) arnimikelsons@MacBook-Pro-2 aaf %
Oh I see. Phoenix.View
has been removed as. default in Phoenix 1.7 so you'll need to update your web module plus all views to the new Phoenix 1.7 setup. This means that you need something like this in AafWeb
(phoenix diff can show all the changes):
def html do
quote do
use Phoenix.Component
# Import convenience functions from controllers
import Phoenix.Controller,
only: [get_csrf_token: 0, view_module: 1, view_template: 1]
# Include general helpers for rendering HTML
unquote(html_helpers())
end
end
defp html_helpers do
quote do
# HTML escaping functionality
import Phoenix.HTML
# Core UI components and translation
import AafWeb.CoreComponents
import AafWeb.Gettext
# Shortcut for generating JS commands
alias Phoenix.LiveView.JS
# Routes generation with the ~p sigil
unquote(verified_routes())
end
end
You can see in the above there's an expectation for AafWeb.CoreComponents
to exist.
Backwards compability with Phoenix.View
is still possible if you are not planning to move over the template components. You'll need to have phoenix_view
as a dependency for this to work. You won't need to change anything, but you must not set :formats
option for the controller in your web module.
If you do want to set that option and still keep the view module then I think you can get away with just renaming them (so it would be AafWeb.Pow.SessionHTML
instead of AafWeb.Pow.SessionView
).
Sorry for the back and fourth here. The Phoenix 1.7 upgrade does kinda work, but all these changes are significant so it means if you enable an option in Phoenix it'll have very different expectations of your project structure. I would have thought you would experience issues with your other view templates as well unless you have updated them to the new structure?
Hi, I'm also upgrading to Phoenix 1.7 and found the same no "new" html template defined for AppWeb.Pow.SessionHTML (the module does not exist)
error.
Adding the code that @danschultzer did not fix the issue.
Are there plans to support Phoenix 1.7 and Elixir 1.15?
I found the issue. There's was an incorrect assumption when Phoenix.View
is available. I've fixed it in #709, which will be merged and new release out later today. Thanks for the reports!
Pow v1.0.32 is out, let me know if it's all working now!
Thanks @danschultzer - using 1.0.32 fixed the issue for me.
@danschultzer Unfortunately it broke my app.
Request: GET /admin/session/new
** (exit) an exception was raised:
** (ArgumentError) no "new" html template defined for MyAppWeb.Pow.SessionView (the module does not exist)
I was using MyAppWeb.Pow.SessionHTML
before and it was working.
Doesn't seem like I can pass an option to pow or anything like that to fix this.
I think
Code.ensure_loaded?(Phoenix.View)
is not good enough. Looking at my dependency graph there are some dependants.
And there's also a case for projects migrating from Views to HTML where they might want to keep part of their code with views.
There's no Phoenix.View
referenced by itself in my app(checked with grep).
@ravensiris ugh, thanks for the report, I'll revert this change and find a better solution.
@ravensiris this should be fixed with #712. I'll get this out later today when I have some free time, but if you want to help please test this and let me know if it works for you:
{:pow, github: "pow-auth/pow", ref: "fix-phoenix-view-namespace"}
My preliminay testing did confirm this works with both your scenario, and resolves OP issue.
This should be fixed in v1.0.33, I couldn't reproduce any issue in any of the scenarios I've tested with in local.
@danschultzer Thanks! It's working with v1.0.33
Trying to upgrade an app, with POW as authentication from 1.6 to 1.7, and getting non-authentication pages to show. But getting the following error on session/new. Are there any instructions on how to move a 1.6 app to 1.7 format?
ArgumentError at GET /session/new
no "new" html template defined for AafWeb.Pow.SessionHTML (the module does not exist)
ArgumentError at GET /session/new
Exception: