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


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

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<aside class="quote no-group" data-username="al2o3cr" data-post="10" data-topic="45452">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/al2o3cr/48/3457_2.png" class="avatar"> al2o3cr:</div>
<blockquote>
<p>You could try running <code>phx.gen.auth</code> in a brand-new Phoenix project and copy over the relevant bits</p>
</blockquote>
</aside>
<p>there’s no easy way to add extra fields there, in case you want to login by other means. (or just have extra fields in general)</p>
<aside class="quote no-group quote-modified" data-username="BLUECALF" data-post="11" data-topic="45452">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/bluecalf/48/26641_2.png" class="avatar"> BLUECALF:</div>
<blockquote>
<p>I did phx.gen.auth Accounts User users</p>
<p>Then changed users schema…</p>
</blockquote>
</aside>
<p>I was in the same situation as OP. The hundreds of test are easily solved with <code>test/support/fixtures/accounts_fixtures.ex</code> and adding the new fields in <code>valid_user_attributes</code>.</p>
<p>but then i started to get dozens of</p>
<blockquote>
<ol start="2">
<li>test GET /users/log_in renders log in page (MyappWeb.UserSessionControllerTest)<br>
test/myapp_web/controllers/user_session_controller_test.exs:11<br>
** (UndefinedFunctionError) function HTML.Form.normalize_value/2 is undefined (module HTML.Form is not available)</li>
</ol>
</blockquote>
<p>and the stack trace shows liveview all over the place, which is confusing as i opted out of liveview features for gen.auth. … most of the failing tests are not using the test fixtures and I suspected that is the cause.</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">post(conn, ~p"/users/log_in", %{
   "user" =&gt; %{"email" =&gt; user.email, "password" =&gt; "invalid_password"}
})
</code></pre>
<p>edit: only 3 tests failed because of the hardcoded values. While the UndefinedFunctionError looks like a generator issue:</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">--- lib/myapp_web/components/core_components.ex
+++ lib/myapp_web/components/core_components.ex
@@ -287,7 +287,7 @@ defmodule MyApp.CoreComponents do
 
   def input(%{type: "checkbox", value: value} = assigns) do
     assigns =
-      assign_new(assigns, :checked, fn -&gt; HTML.Form.normalize_value("checkbox", value) end)
+      assign_new(assigns, :checked, fn -&gt; Phoenix.HTML.Form.normalize_value("checkbox", value) end)
 
</code></pre>
<p>weird. But in the end i guess it is indeed pretty straight forward to add extra fields. Just more involved to actually log in with them…</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="291540" 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/is-there-a-way-to-add-new-fields-to-phx-gen-auth-easier/45452/12">Post #11</a>
	                </div>
	            </div>
              <div id="likers-container-291540" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="291540"
                     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="355534" data-post-id="355534">
  <section>
    <div class="post-wrap">


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

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<aside class="quote no-group" data-username="sodapopcan" data-post="6" data-topic="45452">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/sodapopcan/48/34668_2.png" class="avatar"> sodapopcan:</div>
<blockquote>
<p>Another route I’ve taken in a multi-tenant app is to leave the <code>Accounts</code> context completely alone. Once a user logs in with their email and password, they become an <code>OrgMember</code> in an <code>Orgs</code> context (for example) and choose a username post-registration. <code>OrgMember</code> can either be its own table or it could point to the <code>users</code> table (there are pros and cons to both ways). In either scenario, the only thing <code>OrgMember</code> schema needs to know from <code>User</code> is <code>email</code>. This way, way you have really clean separation between authorization and the rest of your app and you don’t have to futz about with generated code.</p>
</blockquote>
</aside>
<p>Really like this tbh. Is it only for multi-tenant architecture that you recommend this approach?</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="355534" 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/is-there-a-way-to-add-new-fields-to-phx-gen-auth-easier/45452/13">Post #12</a>
	                </div>
	            </div>
              <div id="likers-container-355534" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="355534"
                     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="355535" data-post-id="355535">
  <section>
    <div class="post-wrap">


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

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>Personally I’d suggest this for every application. Keep the “how someone authenticates” separate from what they represent to the business – mostly for authorization purposes. In some projects they might even be able to switch the latter while the former authentication is valid.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="355535" 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/is-there-a-way-to-add-new-fields-to-phx-gen-auth-easier/45452/14">Post #13</a>
	                </div>
	            </div>
              <div id="likers-container-355535" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="355535"
                     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 #13"></div>
  </section>
</div>
    <div class="postbit" id="355542" data-post-id="355542">
  <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>What LKK said <img src="https://forum.elixirforum.com/images/emoji/apple/slight_smile.png?v=15" title=":slight_smile:" class="emoji" alt=":slight_smile:" 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="355542" 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/is-there-a-way-to-add-new-fields-to-phx-gen-auth-easier/45452/15">Post #14</a>
	                </div>
	            </div>
              <div id="likers-container-355542" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="355542"
                     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>