Skip to content

Commit

Permalink
Add fallback for view handling
Browse files Browse the repository at this point in the history
  • Loading branch information
danschultzer committed Sep 5, 2023
1 parent 28dddde commit a0b2f33
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Changelog

## v1.0.33 (TBA)

## Bug fixes

- [`Pow.Phoenix.Controller`] Fixed regression bug with `Phoenix.View` and `:namespace` option
- [`Pow.Phoenix.ViewHelpers`] Now falls back to view named modules to prevent upgrade issues

## v1.0.32 (2023-08-30)

Removed deprecation warnings for Elixir 1.15.
Expand Down
16 changes: 14 additions & 2 deletions lib/pow/phoenix/controllers/view_helpers.ex
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,20 @@ defmodule Pow.Phoenix.ViewHelpers do
def build_view_module(default_view, nil), do: default_view
def build_view_module(default_view, web_module) when is_atom(web_module) do
[base, view] = split_default_view(default_view)

Module.concat([web_module, base, view])
module = Module.concat([web_module, base, view])

case Code.ensure_loaded?(Phoenix.View) and not Code.ensure_loaded?(module) do
# TODO: Remove when Phoenix 1.7 is required
true ->
module
|> to_string()
|> Phoenix.Naming.unsuffix("HTML")
|> Kernel.<>("View")
|> String.to_atom()

false ->
module
end
end

# TODO: Remove `Pow.Phoenix.LayoutView` guard when Phoenix 1.7 is required
Expand Down

0 comments on commit a0b2f33

Please sign in to comment.