<turbo-stream action="append" target="posts_list"><template>    <div class="postbit" id="136386" data-post-id="136386">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="7stud" src="/assets/icons/user-9f439610.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  7stud
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<aside class="quote no-group" data-username="idi527" data-post="11" data-topic="15949">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/letter_avatar_proxy/v4/letter/i/85e7bf/48.png" class="avatar"> idi527:</div>
<blockquote>
<p>Dog.UserManager.Guardian.Plug != Guardian.Plug</p>
</blockquote>
</aside>
<p>First time trying Guardian–I did not know that!</p>
<blockquote>
<p>Seems like you’ve confused one with the other because of</p>
<p><code>alias Dog.{UserManager, UserManager.User, UserManager.Guardian}</code></p>
</blockquote>
<p>And, I checked that line to make sure that <code>Guardian.Plug</code>  was indeed equivalent to <code>Dog.UserManager.Guardian.Plug</code>!  All that code is from the official Guardian “Getting Started Tutorial”.</p>
<p>And, the route problem I was having was due to the tutorial alternately using “/protected” and “/secret” to refer to the Guardian protected route.</p>
<p>By the way, things work when I do:</p>
<pre><code> alias Dog.{UserManager, UserManager.User, UserManager.Guardian}
 ...
 new_conn = Guardian.Plug.sign_in(conn, user)
</code></pre>
<p>So, I guess I was looking at the wrong docs???  This is what my <code>lib/dog/user_manager/guardian.ex</code> file looks like:</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">defmodule Dog.UserManager.Guardian do
  use Guardian, otp_app: :dog
  alias Dog.UserManager

  def subject_for_token(user, _claims) do
    # You can use any value for the subject of your token but
    # it should be useful in retrieving the resource later, see
    # how it being used on `resource_from_claims/1` function.
    # A unique `id` is a good subject, a non-unique email address
    # is a poor subject.

    {:ok, to_string(user.id)}
  end

  def resource_from_claims(%{"sub" =&gt; id}) do
    # Here we'll look up our resource from the claims, the subject can be
    # found in the `"sub"` key. In `above subject_for_token/2` we returned
    # the resource id so here we'll rely on that to look it up.

    case UserManager.get_user(id) do
      nil -&gt; {:error, :user_not_found}
      user -&gt; {:ok, user}
    end
  end

end
</code></pre>
<p>I guess the line:</p>
<pre><code>use Guardian, otp_app: :dog
</code></pre>
<p>injects a Plug module?  I looked at the source code for the Guardian module:</p>
<pre data-code-wrap="elixir"><code class="lang-elixir"> defmacro __using__(opts \\ []) do
    otp_app = Keyword.get(opts, :otp_app)

    # credo:disable-for-next-line Credo.Check.Refactor.LongQuoteBlocks
    quote do
      @behaviour Guardian

      if Code.ensure_loaded?(Plug) do
        __MODULE__
        |&gt; Module.concat(:Plug)    
        |&gt; Module.create(  ## CREATES THE Dog.UserManager.Guardian.Plug MODULE
          quote do
            use Guardian.Plug, unquote(__MODULE__)
          end,
          Macro.Env.location(__ENV__)
        )
      end
</code></pre>
<p>And Guardian.Plug’s <code>__using__()</code> function looks like this:</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">   defmacro __using__(impl) do
      quote do
        ...
        ...
        def sign_in(conn, resource, claims \\ %{}, opts \\ []),
          do: Guardian.Plug.sign_in(conn, implementation(), resource, claims, opts)
</code></pre>
<p>And, there’s the two argument <code>sign_in()</code> function that I lucked into; and, like you said, the way I was calling it originally:</p>
<pre><code>Guardian.Plug.sign_in(conn, Guaridan, user)
</code></pre>
<p>matched the parameter variable <code>claims</code> to user.</p>
<p>lol.  And the original solution to this question was:</p>
<blockquote>
<p>ok found something, I changed it into this:<br>
<code>|&gt; Guardian.Plug.sign_in(user)</code></p>
</blockquote>
<p>Thanks idiot!</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="136386" data-batch-url="/posts/batch_likers">
                        2
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/protocol-enumerable-not-implemented-for-error-with-guardian-login/15949/12">Post #11</a>
	                </div>
	            </div>
              <div id="likers-container-136386" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="136386"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-last-post cat-last-post" title="Last post!"></div>
  </section>
</div>
</template></turbo-stream><turbo-stream action="replace" target="load-more-container"><template><div id="load-more-container" class="load-more-container">
    <span class="all-loaded">— All posts loaded —</span>
</div></template></turbo-stream>