smpallen99 / coherence

Coherence is a full featured, configurable authentication system for Phoenix
MIT License
1.27k stars 225 forks source link

cannot import Coherence.Rememberable.hash/1 because it is undefined or private #304

Open sescobb27 opened 6 years ago

sescobb27 commented 6 years ago

Hi, i'm upgrading from coherence 0.4 to 0.5 and running mix coh.install --reinstall but now i'm getting the following error:

== Compilation error in file lib/twd_web/controllers/coherence/session_controller.ex ==
** (CompileError) lib/twd_web/controllers/coherence/session_controller.ex:12: cannot import Coherence.Rememberable.hash/1 because it is undefined or private
    (elixir) src/elixir_import.erl:77: :elixir_import.calculate/6
    (elixir) src/elixir_import.erl:18: :elixir_import.import/4
defmodule TwdWeb.Coherence.SessionController do
  @moduledoc """
  Handle the authentication actions.

  """
  use Coherence.Web, :controller
  use Timex
  use Coherence.Config

  import Coherence.TrackableService
  import Ecto.Query
  import Coherence.Rememberable, only: [hash: 1, gen_cookie: 3] # error

  alias Coherence.{Rememberable}
  alias Coherence.ControllerHelpers, as: Helpers
  alias Coherence.{ConfirmableService}
  alias Coherence.Messages

  require Logger

  @type schema :: Ecto.Schema.t
  @type conn :: Plug.Conn.t
  @type params :: Map.t

  plug :layout_view, view: Coherence.SessionView
  plug :redirect_logged_in when action in [:new, :create]
  ...
end
ryanhart2 commented 6 years ago

If you look at the latest session controller you will see that the lines import Coherence.Rememberable, only: [hash: 1, gen_cookie: 3] and alias Coherence.{Rememberable} are commented out. In place of these imported functions, the module now defines these local functions:

defp hash(value) do
  schema(Rememberable).hash value
end

defp gen_cookie(user_id, series, token) do
  schema(Rememberable).gen_cookie user_id, series, token
end

You will need to generate new controllers and use git diff to choose which changes to incorporate.