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


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="leejarvis" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/leejarvis/120/37976_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  leejarvis
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<aside class="quote no-group" data-username="bdarla" data-post="34" data-topic="70256">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/bdarla/48/19471_2.png" class="avatar"> bdarla:</div>
<blockquote>
<p>Are there any details on how to opt-in? I cannot find out how to configure this option.</p>
</blockquote>
</aside>
<p>This isn’t a code configuration option (I had assumed that). Once you’ve signed in, you can go to the account settings and opt-in there. From a code perspective you could of course just remove the magic link code which seems straightforward.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="361335" 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/phoenix-1-8-0-rc-0-released/70256/35">Post #34</a>
	                </div>
	            </div>
              <div id="likers-container-361335" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="361335"
                     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 #34"></div>
  </section>
</div>
    <div class="postbit" id="361337" data-post-id="361337">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="bdarla" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/bdarla/120/19471_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  bdarla
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>If this is true, then the opt-in refers to the user and not the developer. I hope that (if this is true), it will change to give the option to the developer.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="361337" data-batch-url="/posts/batch_likers">
                        3
                      </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/phoenix-1-8-0-rc-0-released/70256/36">Post #35</a>
	                </div>
	            </div>
              <div id="likers-container-361337" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="361337"
                     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 #35"></div>
  </section>
</div>
    <div class="postbit" id="361342" data-post-id="361342">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="chrismccord" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/chrismccord/120/24233_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  chrismccord
                      <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 class="user-title">
									<span>Creator of Phoenix</span>
			          </div>
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>Sorry, this should have said <code>remains opt-in via user settings.</code> I’ve updated the post!</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="361342" data-batch-url="/posts/batch_likers">
                        3
                      </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/phoenix-1-8-0-rc-0-released/70256/37">Post #36</a>
	                </div>
	            </div>
              <div id="likers-container-361342" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="361342"
                     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 #36"></div>
  </section>
</div>
    <div class="postbit" id="361343" data-post-id="361343">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="bdarla" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/bdarla/120/19471_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  bdarla
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>Thanks for the clarification!</p>
<p>Moreover, I just noticed in the provided video the easy way to confirm the email by visiting the mailbox. It escaped my attention at first.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="361343" 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/phoenix-1-8-0-rc-0-released/70256/38">Post #37</a>
	                </div>
	            </div>
              <div id="likers-container-361343" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="361343"
                     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 #37"></div>
  </section>
</div>
    <div class="postbit" id="361360" data-post-id="361360">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="jam" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/jam/120/36266_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  jam
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>That’s fair. I imagine there was a good reason why you chose to include scope first. Curious to learn the thinking there. As someone fairly new to elixir, I’m still learning best practices. <img src="https://forum.elixirforum.com/images/emoji/apple/slightly_smiling_face.png?v=15" title=":slightly_smiling_face:" class="emoji" alt=":slightly_smiling_face:" loading="lazy" width="20" height="20"></p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="361360" 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/phoenix-1-8-0-rc-0-released/70256/39">Post #38</a>
	                </div>
	            </div>
              <div id="likers-container-361360" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="361360"
                     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 #38"></div>
  </section>
</div>
    <div class="postbit" id="361361" data-post-id="361361">
  <section>
    <div class="post-wrap">


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

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>I know what I would like 2.0 (Phoenix/LiveView) to have: suitability for mobile deployment. I read in a post by <a class="mention" href="/u/josevalim" rel="nofollow">@josevalim</a> that LiveView <a href="https://forum.elixirforum.com/t/regretting-questioning-my-current-stack-flutter-elixir-as-solo-dev-for-mobile-app/55731/7" rel="nofollow">wasn’t ready for mobile deployment</a>. So, without really understanding why (and I still don’t), I’ve started my new mobile app development using:</p>
<ol>
<li>React Native</li>
<li>Expo</li>
<li>Firebase</li>
<li>GlueStack.</li>
</ol>
<p>What a convoluted, complex nightmare. I long for the beauty of Phoenix/LiveView.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="361361" 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/phoenix-1-8-0-rc-0-released/70256/40">Post #39</a>
	                </div>
	            </div>
              <div id="likers-container-361361" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="361361"
                     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 #39"></div>
  </section>
</div>
    <div class="postbit" id="361362" data-post-id="361362">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="sodapopcan" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/sodapopcan/120/34668_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  sodapopcan
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>From having used this pattern for a long time now, having it as the first parameter codifies right in the signature that it’s required.  If it’s optional, it’s clearer to make a separate head that takes the schema as the first parameter.  Otherwise, having it as an option (<code>scope: scope)</code> means you need extra code to always grab it from options.  This may not seem like much, but it means you’re always adding extra code to every function whether the option is required or not and testing against that.</p>
<p>Now, I’m not saying that having as an option is bad—Ash does this, but it’s not exactly a trivial implementation and has measures to make things clearer.  For example, you can explicitly tell Ash that the actor (scope) is required for every function in an entire domain (context) in one line.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="361362" data-batch-url="/posts/batch_likers">
                        1
                      </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/phoenix-1-8-0-rc-0-released/70256/41">Post #40</a>
	                </div>
	            </div>
              <div id="likers-container-361362" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="361362"
                     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 #40"></div>
  </section>
</div>
    <div class="postbit" id="361448" data-post-id="361448">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="AlchemistCamp" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/AlchemistCamp/120/8823_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  AlchemistCamp
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>I’m curious to understand a bit more what you had in mind. In the scopes guide, there’s a blog example that goes through the following three steps:</p>
<ol>
<li>run the auth generator</li>
<li>run the live generator to create blog posts and add the routes to the router</li>
<li>run the migration (which includes a reference to user_id thanks to step 1)</li>
</ol>
<p>Now, the app has blog posts, but they’re locked down for every action. Let’s suppose the would be blog creator wants all site visitors to be able to read the blog posts instead of only the authors being able to read their own posts. Also they want visitors to be able to read blog posts without creating an account.</p>
<p>So, they’ll want to move the router line for <code>live "/posts/:id", PostLive.Show, :show</code> and probably <code>live "/posts", PostLive.Index, :index</code> out of the <code>live_session</code> that requires authenticated users.</p>
<p>However, when doing this, there will be <code>no function clause matching</code> errors for logged out users visiting <code>/posts</code> or <code>/post/1</code>, etc. After editing the context to resolve that, the <code>Blog.get_post!/2</code> will fail.</p>
<p>In this case, the next steps might be something like…</p>
<ol start="4">
<li>In the Blog context, add a function head to handle nil scopes<code>def subscribe_posts(nil), do: :ok</code></li>
<li>Do the same for <code>broadcast/2</code></li>
<li>Make alternate versions of <code>get_post</code> and <code>list_posts</code> that don’t include the <code>user_id</code> in the query sent to Ecto.</li>
</ol>
<p>Is this roughly the workflow you envision people using for something that needs to be more open than the new default?</p>
<p><strong>Edit</strong>: I’m guessing the answer is probably not, since this means navigating across live_sessions to go from one Blog action to another (and doing full page reloads as a result).</p>
<p>The pattern I’ve used for times in the past when some actions for a schema require authenticated users and some don’t has been to put them all in the same live_session block in the router and then do the authorization from the mount function of individual live views using the <code>LiveHelpers.assign_user/2</code> (from previous phx generators) to ensure authentication.</p>
<p>Is there a pattern in particular you’re hoping to steer people towards in this scenario now?</p>
<p><strong>Additional Edit</strong>: How about this pattern for when only some actions in a LiveView require authentication?</p>
<p>In UserAuth, create a custom on_mount like this:</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">def on_mount({:require_authenticated_unless, allowed_actions}, _params, session, socket) do
  socket = mount_current_scope(socket, session)
  current_user = socket.assigns.current_scope &amp;&amp; socket.assigns.current_scope.user

  action_always_allowed = socket.assigns.live_action in allowed_actions

  if current_user || action_always_allowed do
    {:cont, socket}
  else
    socket =
      socket
      |&gt; Phoenix.LiveView.put_flash(:error, "You must log in to access this page.")
      |&gt; Phoenix.LiveView.redirect(to: ~p"/users/log-in")

    {:halt, socket}
  end
end
</code></pre>
<p>Then in any LiveView where it’s needed, use the custom on_mount hook to open specific actions (while still requiring authentication for all others)?</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">  on_mount {AppWeb.UserAuth, {:require_authenticated_unless, [:show]}}
</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="361448" data-batch-url="/posts/batch_likers">
                        3
                      </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/phoenix-1-8-0-rc-0-released/70256/42">Post #41</a>
	                </div>
	            </div>
              <div id="likers-container-361448" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="361448"
                     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 #41"></div>
  </section>
</div>
    <div class="postbit" id="361456" data-post-id="361456">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="terenceponce" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/terenceponce/120/15902_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  terenceponce
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>Congratulations on the release! I have a question about scopes.</p>
<p>I’m looking at the <a href="https://hexdocs.pm/phoenix/1.8.0-rc.0/scopes.html#defining-scopes" rel="noopener nofollow ugc">documentation for Scopes</a> and I was wondering about the <code>test_data_fixture</code> option for defining scopes. It looks like a required option, but what should I do with this if I’m using factories (ex_machina) instead of fixtures?</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="361456" 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/phoenix-1-8-0-rc-0-released/70256/43">Post #42</a>
	                </div>
	            </div>
              <div id="likers-container-361456" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="361456"
                     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 #42"></div>
  </section>
</div>
    <div class="postbit" id="361477" data-post-id="361477">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="mgibowski" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/mgibowski/120/21221_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  mgibowski
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>Define a module with fixture functions that wrap factories, like:</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">def user_scope_fixture do
  insert(:user)
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="361477" data-batch-url="/posts/batch_likers">
                        1
                      </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/phoenix-1-8-0-rc-0-released/70256/44">Post #43</a>
	                </div>
	            </div>
              <div id="likers-container-361477" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="361477"
                     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 #43"></div>
  </section>
</div>
</template></turbo-stream><turbo-stream action="replace" target="load-more-container"><template><div id="load-more-container" class="load-more-container">
    <a class="load-more-button" data-turbo-stream="true" href="/topics/70256/load_more?page=5">Load more posts</a>
</div></template></turbo-stream>