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


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="PavelZX" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/PavelZX/120/12865_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  PavelZX
                    <span class="op-star" title="Thread Starter">
                      <img alt="OP" class="op-star-icon" src="/assets/thread-icons/thread-icon-thread-starter-df91e872.png" />
                    </span>
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<aside class="quote no-group" data-username="PavelZX" data-post="10" data-topic="19103">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/pavelzx/48/12865_2.png" class="avatar"> PavelZX:</div>
<blockquote>
<p>Guardian.encode_and_sign</p>
</blockquote>
</aside>
<aside class="onebox allowlistedgeneric" data-onebox-src="https://elixirschool.com/ru/lessons/misc/guardian">
  <header class="source">
      <img src="https://elixirschool.com/favicon.ico" class="site-icon" alt="" width="48" height="48">

      <a href="https://elixirschool.com/ru/lessons/misc/guardian" target="_blank" rel="noopener nofollow ugc">elixirschool.com</a>
  </header>

  <article class="onebox-body">
    

<h3><a href="https://elixirschool.com/ru/lessons/misc/guardian" target="_blank" rel="noopener nofollow ugc">Guardian (Основы)
 · Elixir School</a></h3>



  </article>

  <div class="onebox-metadata">
    
    
  </div>

  <div style="clear: both"></div>
</aside>
 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="110230" data-batch-url="/posts/batch_likers">
                        0
                      </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/ecto-association-notloaded/19103/12">Post #11</a>
	                </div>
	            </div>
              <div id="likers-container-110230" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="110230"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #11"></div>
  </section>
</div>
    <div class="postbit" id="110231" data-post-id="110231">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="PavelZX" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/PavelZX/120/12865_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  PavelZX
                    <span class="op-star" title="Thread Starter">
                      <img alt="OP" class="op-star-icon" src="/assets/thread-icons/thread-icon-thread-starter-df91e872.png" />
                    </span>
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<pre><code>defmodule ImconWeb.Router do
  use ImconWeb, :router

  pipeline :browser do
    plug :accepts, ["html"]
    plug :fetch_session
    plug :fetch_flash
    plug :protect_from_forgery
    plug :put_secure_browser_headers
  end

  pipeline :auth do
    plug Imcon.Plugs
  end

  pipeline :api do
    plug :accepts, ["json", "xml"]
    plug :fetch_session
  end

  scope "/api", ImconWeb do
    pipe_through :api

    scope "/v1" do
      post "/registrations", RegistrationController, :create

      post "/sessions", SessionController, :create
      delete "/sessions", SessionController, :delete

      get "/current_user", CurrentUserController, :show

      resources "/board", BoardController, only: [:index, :create] do
      resources "/card", CardController, only: [:show]
      end
    end
  end

  scope "/", ImconWeb do
    pipe_through :browser # Use the default browser stack

    get "/*path", PageController, :index
  end
end
</code></pre>
<p>…</p>
<pre><code>defmodule Imcon.Plugs do

  use Guardian.Plug.Pipeline,
    otp_app: :imcon,
    error_handler: ImconWeb.ErrorHandler,
    module: Imcon.Auth.Guard

  plug Guardian.Plug.VerifySession, claims: %{"typ" =&gt; "access"}
  plug Guardian.Plug.EnsureAuthenticated, handler: ImconWeb.SessionController
  plug Guardian.Plug.LoadResource, allow_blank: true

end
</code></pre>
<p>…</p>
<pre><code>defmodule Imcon.Auth.Guard do
  use Guardian, otp_app: :imcon

  def subject_for_token(user, _claims) do
    sub = to_string(user.id)
    {:ok, sub}
  end

  def subject_for_token(_, _) do
    {:error, :reason_for_error}
  end

  def resource_from_claims(claims) do
    id = claims["sub"]
    user = Imcon.Auth.get_user(id)
    {:ok, user}
  end

  def resource_from_claims(_claims) do
    {:error, :reason_for_error}
  end

end
</code></pre> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="110231" data-batch-url="/posts/batch_likers">
                        0
                      </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/ecto-association-notloaded/19103/13">Post #12</a>
	                </div>
	            </div>
              <div id="likers-container-110231" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="110231"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #12"></div>
  </section>
</div>
    <div class="postbit" id="110339" data-post-id="110339">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="PavelZX" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/PavelZX/120/12865_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  PavelZX
                    <span class="op-star" title="Thread Starter">
                      <img alt="OP" class="op-star-icon" src="/assets/thread-icons/thread-icon-thread-starter-df91e872.png" />
                    </span>
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>I tried this way and that, it turns out that this error occurs when trying to remake authentification under Gardian 1. I did it on the basis of a working application, but I mistook something somewhere, most likely. <a href="https://github.com/danbee/chess" class="inline-onebox" rel="noopener nofollow ugc">GitHub - danbee/chess: Multiplayer chess game in Elixir/Phoenix and React · GitHub</a></p>
<p>He took an example at random, thought it would be easier to build on it. Accordingly, several functions in the new Guardian work differently, so the rules as best they could, so that during the compilation they would not swear.</p>
<p>I read the forum, this is an old problem, how to organize authentication and authorization. In the Phoenix from the box it is not, as for example in Django.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="110339" data-batch-url="/posts/batch_likers">
                        0
                      </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/ecto-association-notloaded/19103/14">Post #13</a>
	                </div>
	            </div>
              <div id="likers-container-110339" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="110339"
                     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>