Closed praveenperera closed 4 years ago
You have to use the pow_assent_login_with_provider/1
method name:
defmodule TunevuPlayer.Pow.Messages do
use Pow.Phoenix.Messages
use Pow.Extension.Phoenix.Messages,
extensions: [PowAssent]
def pow_assent_login_with_provider(conn), do: Phoenix.Naming.humanize(conn.params["provider"])
end
And set messages_backend: TunevuPlayer.Pow.Messages
in the config.
Using Phoenix.Naming.humanize(conn.params["provider"])
would mean that it says Twitter for the :twitter
strategy. It's better in case you add more providers in the future.
Oh I see now, I have to change
defmodule TunevuPlayer.Pow.Messages do
use Pow.Phoenix.Messages
use Pow.Extension.Phoenix.Messages,
extensions: [PowAssent]
def login_with_provider(_conn) do
"Twitter"
end
end
TO
defmodule TunevuPlayer.Pow.Messages do
use Pow.Phoenix.Messages
use Pow.Extension.Phoenix.Messages,
extensions: [PowAssent]
def pow_assent_login_with_provider(_conn) do
"Twitter"
end
end
Yup, extension messages require that you add the extension namespace to the method name. It's to prevent name collision.
Yes that makes sense, I should have deduced that when I saw the example function was pow_assent_signed_in
, but I overlooked it.
I ended up copying the function name I thought I needed (login_with_provider
) directly.
What do you think about me adding a note to the PowAssent docs saying you have to add the extension namespace to the function name?
Yeah, it isn't clear from the docs at all. I'm updating them, thanks!
Glad I could help 😊
Done #123 :rocket:
I tried to add a custom message using
login_with_provider()
following instructions that are here:https://hexdocs.pm/pow_assent/PowAssent.Phoenix.Messages.html#content
I added it as a
messages_backend
Here is my module:
However, when using the view helpers I get "Sign in with Twitter" instead of just "Twitter"
This is how I made it work manually: