I start with phx.gen.auth and i am trying to add an api endpoint with login capabilities,
i follow the getstart documentation but i had an error:
this is familiar to somebody?
def create(conn = %{body_params: %Schemas.LoginRequest{user: %{email: email, password: password}}}, _params) do
case Accounts.get_user_by_email_and_password(email, password) do
%Accounts.User{} = user ->
IO.inspect(user)
{:ok, jwt, _full_claims} = Guardian.encode_and_sign(user, %{}) <---- ERROR
conn
|> render("create.json", user: user, jwt: jwt)
nil ->
conn
|> put_status(401)
|> render("error.json", message: "User could not be authenticated")
end
end
Expected Result
retrive the token
Actual Result
[error] #PID<0.1421.0> running BackendWeb.Endpoint (connection #PID<0.1404.0>, stream id 4) terminated
Server: localhost:4000 (http)
Request: POST /api/users/log_in
(exit) an exception was raised:
(ArgumentError) errors were found at the given arguments:
Steps to Reproduce
Hello everyone,
I start with phx.gen.auth and i am trying to add an api endpoint with login capabilities, i follow the getstart documentation but i had an error: this is familiar to somebody?
my config.ex
the error happends here:
Expected Result
retrive the token
Actual Result
[error] #PID<0.1421.0> running BackendWeb.Endpoint (connection #PID<0.1404.0>, stream id 4) terminated Server: localhost:4000 (http) Request: POST /api/users/log_in (exit) an exception was raised: (ArgumentError) errors were found at the given arguments:
1st argument: not an atom