You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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:
defmodule ShiritoriWeb.Auth.AuthenticateTokenCookie do
use Phauxth.Authenticate.Token
@impl true
def authenticate(%Plug.Conn{req_cookies: %{"token" => token}}, opts) do
verify_token(token, opts, opts)
end
end
The warning from ElixirLS:
got "@impl true" for function authenticate/2 but no behaviour specifies such callback. The known callbacks are:
* Phauxth.Authenticate.Base.authenticate/3 (function)
* Plug.call/2 (function)
* Phauxth.Authenticate.Token.get_token/3 (function)
* Plug.init/1 (function)
* Phauxth.Authenticate.Base.report/2 (function)
* Phauxth.Authenticate.Base.set_user/2 (function)
furthermore verify_token expects 3 parameters but the verify_token from the guide I'm referring to, only pass 2 parameters.
From the docs:
defmodule Phauxth.AuthenticateTokenCookie do
use Phauxth.Authenticate.Token
@impl true
def authenticate(%Plug.Conn{req_cookies: %{"access_token" => token}}, opts) do
verify_token(token, opts)
end
end
I found a workaround but involves removing the @impl true for the authenticate/2 and passing opts to 2nd and 3rd parameter of verify_token:
def authenticate(%Plug.Conn{req_cookies: %{"token" => token}}, opts) do
verify_token(token, opts, opts)
end
The text was updated successfully, but these errors were encountered:
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
Environment
Erlang/OTP 22 [erts-10.6.2] [source] [64-bit] [smp:4:4] [ds:4:4:10] [async-threads:1] [hipe]
Elixir 1.9.4 (compiled with Erlang/OTP 21)
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
:The text was updated successfully, but these errors were encountered: