Closed jhefreyzz closed 4 years ago
Thanks for pointing that out. It looks like the examples in the documentation are wrong.
The example should be:
defmodule Phauxth.AuthenticateTokenCookie do
use Phauxth.Authenticate.Token
@impl true
def authenticate(%Plug.Conn{req_cookies: %{"access_token" => token}}, user_context, opts) do
verify_token(token, user_context, opts)
end
end
And I will update the docs later this week.
Documentation updated in version 2.3.2
Environment
Issue
It seems like the arity for authenticate callback is incorrect. Based on the guide from the docs: https://hexdocs.pm/phauxth/Phauxth.Authenticate.Token.html, the function is authenticate/2. I implemented the same way since I'm using cookie to store the token but Phauxth.Authenticate.Token expects authenticate/3.
My implementation:
The warning from ElixirLS:
furthermore
verify_token
expects 3 parameters but theverify_token
from the guide I'm referring to, only pass 2 parameters.From the docs:
I found a workaround but involves removing the
@impl true
for theauthenticate/2
and passing opts to 2nd and 3rd parameter ofverify_token
: