Closed puruzio closed 7 years ago
Could you let me know the output of IO.inspect(token)
?
If it's nil or there's an error, let me know the output to IO.inspect(user)
(just above the token =
line).
If IO.inspect(token)
returns a string, let me know the output of assign(:user_token, token) |> IO.inspect
.
Actually it doesn't seem to hit set_current_user
line at all. Is there anything that needs to be wired up other than adding the plug Openmaize.Authenticate
in the router.ex?
I did follow the steps indicated at https://github.com/riverrun/openmaize for installation and setup.
Adding the following to router.ex did the trick. Thanks.
pipeline :browser do
...
plug Openmaize.Authenticate
plug :put_user_token
end
defp put_user_token(conn, _) do
if current_user = conn.assigns[:current_user] do
token = Phoenix.Token.sign(conn, "user socket", current_user.id)
assign(conn, :user_token, token)
else
conn
end
end
Glad to hear you got it working.
I'm trying to get Openmaize to work with Phoenix.Token for user authentication. I tried to modify
authenticate.ex
in the library like this, but it doesn't seem to be called as I was expecting it.Can you please tell me what is the right way to use Phoenix.Token with Openmaize?