pow icon indicating copy to clipboard operation
pow copied to clipboard

Explicit controller callbacks

Open danschultzer opened this issue 6 years ago • 1 comments
trafficstars

This is based on https://github.com/danschultzer/pow/issues/66#issuecomment-457951767.

So let's say that we want something like the following:

  1. Redirect users to a custom page when e-mail hasn't been yet confirmed.
  2. Permit users to sign in without confirming the e-mail first

This currently requires that you set up custom controllers to modify the flow. Furthermore, the extensions are defined in the config which makes it far easier to make mistakes as it will load the extensions in the order it has been defined.

https://github.com/danschultzer/pow/blob/8fcc82627ecd3e3c2cc9b5854d116442a5a4201b/lib/pow/extension/phoenix/controllers/controller_callbacks.ex#L19-L24

It would be great to get it working similar to plug. It's much easier to understand how to modify the flow this way:

defmodule MyAppWeb.PowControllerCallbacks do
   use Pow.Phoenix.ControllerCallbacks

   # Default extension callbacks
   extension PowEmailConfirmation
   extension PowPersistentPassword

   # Selective extension callbacks
   extension PowEmailConfirmation, except: [Pow.Phoenix.RegistrationController => :new]

   # Override specific callback
   extension PowEmailConfirmation, Pow.Phoenix.RegistrationController, :new, fn _params ->
   end

   # Custom callback
   before_process Pow.Phoenix.RegistrationController, :new, fn _params ->
   end
end

I'll work on this and see what feels better.

danschultzer avatar Feb 12 '19 01:02 danschultzer

:+1:

augnustin avatar Feb 26 '20 13:02 augnustin