Coder Social home page Coder Social logo

Comments (12)

danschultzer avatar danschultzer commented on June 15, 2024 1

Pow v1.0.32 is out, let me know if it's all working now!

from pow.

danschultzer avatar danschultzer commented on June 15, 2024

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.

from pow.

arnimikelsons avatar arnimikelsons commented on June 15, 2024

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 %

from pow.

danschultzer avatar danschultzer commented on June 15, 2024

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?

from pow.

jaimeiniesta avatar jaimeiniesta commented on June 15, 2024

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?

from pow.

danschultzer avatar danschultzer commented on June 15, 2024

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!

from pow.

jaimeiniesta avatar jaimeiniesta commented on June 15, 2024

Thanks @danschultzer - using 1.0.32 fixed the issue for me.

from pow.

ravensiris avatar ravensiris commented on June 15, 2024

@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).

from pow.

danschultzer avatar danschultzer commented on June 15, 2024

@ravensiris ugh, thanks for the report, I'll revert this change and find a better solution.

from pow.

danschultzer avatar danschultzer commented on June 15, 2024

@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.

from pow.

danschultzer avatar danschultzer commented on June 15, 2024

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.

from pow.

ravensiris avatar ravensiris commented on June 15, 2024

@danschultzer Thanks! It's working with v1.0.33

from pow.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.