Problem with Guardian.Verify.Session

I am signing in users using:

  def sign_in(conn, params) do
    with %User{} = user <- Repo.get_by(User, email: params["email"], provider: "db") do
      with {:ok, token, _claims} <- Accounts.authenticate(%{user: user, password: params["password"]}) do
      conn = Mango.Guardian.Plug.sign_in(conn, user, %{key: token})
      json conn, %{authinticated: "true", logged_in_as: user.email, institute_id: user.institute_id, expires_at: _claims["exp"]}
      end 
    end
  end

The cookie is set on the browser, however all subsequent requests to protected paths return error 401. Any idea what might be going on here? Thank you.

It is working now, cannot understand what the problem was, but it is working now.

Might be the spelling mistake in the json response — authinticated?

1 Like

You should not have been able to use _claims further in the code at all, the underscore at the front is basically a way to denote an unused variable.

1 Like