<turbo-stream action="append" target="posts_list"><template>    <div class="postbit" id="156545" data-post-id="156545">
  <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">
								<aside class="quote no-group" data-username="danschultzer" data-post="11" data-topic="27867">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/danschultzer/48/4942_2.png" class="avatar"> danschultzer:</div>
<blockquote>
<p>Can you share the stack trace?</p>
</blockquote>
</aside>
<p>Sure thing, this is what it looks like:<br>
GET /auth/github/callback<br>
[debug] Processing with PowAssent.Phoenix.AuthorizationController.callback/2<br>
Parameters: %{“code” =&gt; “13eec5f249e194d7085a”, “provider” =&gt; “github”, “state” =&gt; “9b20d1c24ade88cff3ee6fb38e1bc5e06daea3f33bf6b53”}<br>
Pipelines: [:browser]<br>
warning: This request will NOT be verified for valid SSL certificate<br>
(assent) lib/assent/http_adapter/httpc.ex:22: Assent.HTTPAdapter.Httpc.request/5<br>
(assent) lib/assent/strategy.ex:42: Assent.Strategy.request/5<br>
(assent) lib/assent/strategies/oauth2.ex:222: Assent.Strategy.OAuth2.get_access_token/2<br>
(assent) lib/assent/strategies/oauth2.ex:119: Assent.Strategy.OAuth2.callback/3<br>
(assent) lib/assent/strategies/oauth2/base.ex:69: Assent.Strategy.OAuth2.Base.callback/3<br>
(pow_assent) lib/pow_assent/plug.ex:74: PowAssent.Plug.callback/4<br>
(pow_assent) lib/pow_assent/phoenix/controllers/authorization_controller.ex:44: PowAssent.Phoenix.AuthorizationController.process_callback/2<br>
(pow) lib/pow/phoenix/controllers/controller.ex:99: Pow.Phoenix.Controller.action/3<br>
(pow_assent) lib/pow_assent/phoenix/controllers/authorization_controller.ex:1: PowAssent.Phoenix.AuthorizationController.action/2<br>
(pow_assent) lib/pow_assent/phoenix/controllers/authorization_controller.ex:1: PowAssent.Phoenix.AuthorizationController.phoenix_controller_pipeline/2<br>
(phoenix) lib/phoenix/router.ex:288: Phoenix.Router.<strong>call</strong>/2<br>
(my_app) lib/my_app_web/endpoint.ex:1: MyAppWeb.Endpoint.plug_builder_call/2<br>
(my_app) lib/plug/debugger.ex:122: MyAppWeb.Endpoint.“call (overridable 3)”/2<br>
(my_app) lib/my_app_web/endpoint.ex:1: MyAppWeb.Endpoint.call/2<br>
(phoenix) lib/phoenix/endpoint/cowboy2_handler.ex:42: Phoenix.Endpoint.Cowboy2Handler.init/4<br>
(cowboy) /Users/me/my_app/deps/cowboy/src/cowboy_handler.erl:41: :cowboy_handler.execute/2<br>
(cowboy) /Users/me/my_app/deps/cowboy/src/cowboy_stream_h.erl:320: :cowboy_stream_h.execute/3</p>
<p>warning: This request will NOT be verified for valid SSL certificate<br>
(assent) lib/assent/http_adapter/httpc.ex:22: Assent.HTTPAdapter.Httpc.request/5<br>
(assent) lib/assent/strategy.ex:42: Assent.Strategy.request/5<br>
(assent) lib/assent/strategies/oauth2.ex:256: Assent.Strategy.OAuth2.get/4<br>
(assent) lib/assent/strategies/oauth2.ex:266: Assent.Strategy.OAuth2.get_user/3<br>
(assent) lib/assent/strategies/github.ex:57: Assent.Strategy.Github.get_user/3<br>
(assent) lib/assent/strategies/oauth2.ex:237: Assent.Strategy.OAuth2.fetch_user/3<br>
(assent) lib/assent/strategies/oauth2/base.ex:69: Assent.Strategy.OAuth2.Base.callback/3<br>
(pow_assent) lib/pow_assent/plug.ex:74: PowAssent.Plug.callback/4<br>
(pow_assent) lib/pow_assent/phoenix/controllers/authorization_controller.ex:44: PowAssent.Phoenix.AuthorizationController.process_callback/2<br>
(pow) lib/pow/phoenix/controllers/controller.ex:99: Pow.Phoenix.Controller.action/3<br>
(pow_assent) lib/pow_assent/phoenix/controllers/authorization_controller.ex:1: PowAssent.Phoenix.AuthorizationController.action/2<br>
(pow_assent) lib/pow_assent/phoenix/controllers/authorization_controller.ex:1: PowAssent.Phoenix.AuthorizationController.phoenix_controller_pipeline/2<br>
(phoenix) lib/phoenix/router.ex:288: Phoenix.Router.<strong>call</strong>/2<br>
(my_app) lib/my_app_web/endpoint.ex:1: MyAppWeb.Endpoint.plug_builder_call/2<br>
(my_app) lib/plug/debugger.ex:122: MyAppWeb.Endpoint.“call (overridable 3)”/2<br>
(my_app) lib/my_app_web/endpoint.ex:1: MyAppWeb.Endpoint.call/2<br>
(phoenix) lib/phoenix/endpoint/cowboy2_handler.ex:42: Phoenix.Endpoint.Cowboy2Handler.init/4</p>
<p>warning: This request will NOT be verified for valid SSL certificate<br>
(assent) lib/assent/http_adapter/httpc.ex:22: Assent.HTTPAdapter.Httpc.request/5<br>
(assent) lib/assent/strategy.ex:42: Assent.Strategy.request/5<br>
(assent) lib/assent/strategies/github.ex:70: Assent.Strategy.Github.get_email/4<br>
(assent) lib/assent/strategies/oauth2.ex:237: Assent.Strategy.OAuth2.fetch_user/3<br>
(assent) lib/assent/strategies/oauth2/base.ex:69: Assent.Strategy.OAuth2.Base.callback/3<br>
(pow_assent) lib/pow_assent/plug.ex:74: PowAssent.Plug.callback/4<br>
(pow_assent) lib/pow_assent/phoenix/controllers/authorization_controller.ex:44: PowAssent.Phoenix.AuthorizationController.process_callback/2<br>
(pow) lib/pow/phoenix/controllers/controller.ex:99: Pow.Phoenix.Controller.action/3<br>
(pow_assent) lib/pow_assent/phoenix/controllers/authorization_controller.ex:1: PowAssent.Phoenix.AuthorizationController.action/2<br>
(pow_assent) lib/pow_assent/phoenix/controllers/authorization_controller.ex:1: PowAssent.Phoenix.AuthorizationController.phoenix_controller_pipeline/2<br>
(phoenix) lib/phoenix/router.ex:288: Phoenix.Router.<strong>call</strong>/2<br>
(my_app) lib/my_app_web/endpoint.ex:1: MyAppWeb.Endpoint.plug_builder_call/2<br>
(my_app) lib/plug/debugger.ex:122: MyAppWeb.Endpoint.“call (overridable 3)”/2<br>
(my_app) lib/my_app_web/endpoint.ex:1: MyAppWeb.Endpoint.call/2<br>
(phoenix) lib/phoenix/endpoint/cowboy2_handler.ex:42: Phoenix.Endpoint.Cowboy2Handler.init/4<br>
(cowboy) /Users/me/my_app/deps/cowboy/src/cowboy_handler.erl:41: :cowboy_handler.execute/2<br>
(cowboy) /Users/me/my_app/deps/cowboy/src/cowboy_stream_h.erl:320: :cowboy_stream_h.execute/3</p>
<p>[debug] QUERY OK source=“user_identities” db=0.9ms decode=1.4ms queue=1.2ms idle=7355.3ms<br>
SELECT u1.“id”, u1.“password_hash”, u1.“email”, u1.“inserted_at”, u1.“updated_at” FROM “user_identities” AS u0 LEFT OUTER JOIN “users” AS u1 ON u1.“id” = u0.“user_id” WHERE ((u0.“provider” = $1) AND (u0.“uid” = $2)) [“github”, “236820”]<br>
[debug] QUERY OK db=0.2ms idle=7438.4ms<br>
begin <span class="chcklst-box fa fa-square-o"></span><br>
[debug] QUERY ERROR db=8.8ms<br>
INSERT INTO “users” (“email”,“inserted_at”,“updated_at”) VALUES ($1,$2,$3) RETURNING “id” [“<a href="mailto:person@example.com" rel="nofollow">person@example.com</a>”, ~N[2019-12-30 14:54:31], ~N[2019-12-30 14:54:31]]<br>
[debug] QUERY OK db=0.1ms<br>
rollback <span class="chcklst-box fa fa-square-o"></span><br>
[info] Sent 302 in 2557ms<br>
[info] GET /auth/github/add-user-id<br>
[debug] Processing with PowAssent.Phoenix.RegistrationController.add_user_id/2<br>
Parameters: %{“provider” =&gt; “github”}<br>
Pipelines: [:browser]<br>
[info] Sent 500 in 59ms<br>
[error] <a class="hashtag-cooked" href="/tag/pid/2279" data-type="tag" data-slug="pid" data-id="2279" data-style-type="icon" data-icon="tag" rel="nofollow"><span class="hashtag-icon-placeholder"><svg class="fa d-icon d-icon-square-full svg-icon svg-node"><use href="#square-full"></use></svg></span><span>pid</span></a>&lt;0.496.0&gt; running MyAppWeb.Endpoint (connection <a class="hashtag-cooked" href="/tag/pid/2279" data-type="tag" data-slug="pid" data-id="2279" data-style-type="icon" data-icon="tag" rel="nofollow"><span class="hashtag-icon-placeholder"><svg class="fa d-icon d-icon-square-full svg-icon svg-node"><use href="#square-full"></use></svg></span><span>pid</span></a>&lt;0.464.0&gt;, stream id 8) terminated<br>
Server: localhost:4000 (http)<br>
Request: GET /auth/github/add-user-id<br>
** (exit) an exception was raised:<br>
** (UndefinedFunctionError) function MyAppWeb.PowAssent.RegistrationView.render/2 is undefined (module MyAppWeb.PowAssent.RegistrationView is not available)<br>
MyAppWeb.PowAssent.RegistrationView.render(“add_user_id.html”, %{action: “/auth/github/create”, changeset: <span class="hashtag-raw">#Ecto.Changeset</span>&lt;action: nil, changes: %{}, errors: [password_hash: {“can’t be blank”, [validation: :required]}, password: {“can’t be blank”, [validation: :required]}, email: {“can’t be blank”, [validation: :required]}], data: <span class="hashtag-raw">#MyApp.Users.User</span>&lt;&gt;, valid?: false&gt;, conn: %Plug.Conn{adapter: {Plug.Cowboy.Conn, :…}, assigns: %{action: “/auth/github/create”, changeset: <span class="hashtag-raw">#Ecto.Changeset</span>&lt;action: nil, changes: %{}, errors: [password_hash: {“can’t be blank”, [validation: :required]}, password: {“can’t be blank”, [validation: :required]}, email: {“can’t be blank”, [validation: :required]}], data: <span class="hashtag-raw">#MyApp.Users.User</span>&lt;&gt;, valid?: false&gt;, current_user: nil, layout: {MyAppWeb.LayoutView, “app.html”}}, before_send: [<a class="hashtag-cooked" href="/tag/function/1465" data-type="tag" data-slug="function" data-id="1465" data-style-type="icon" data-icon="tag" rel="nofollow"><span class="hashtag-icon-placeholder"><svg class="fa d-icon d-icon-square-full svg-icon svg-node"><use href="#square-full"></use></svg></span><span>function</span></a>&lt;0.61503622/1 in Plug.CSRFProtection.call/2&gt;, <a class="hashtag-cooked" href="/tag/function/1465" data-type="tag" data-slug="function" data-id="1465" data-style-type="icon" data-icon="tag" rel="nofollow"><span class="hashtag-icon-placeholder"><svg class="fa d-icon d-icon-square-full svg-icon svg-node"><use href="#square-full"></use></svg></span><span>function</span></a>&lt;2.10523259/1 in Phoenix.Controller.fetch_flash/2&gt;, <a class="hashtag-cooked" href="/tag/function/1465" data-type="tag" data-slug="function" data-id="1465" data-style-type="icon" data-icon="tag" rel="nofollow"><span class="hashtag-icon-placeholder"><svg class="fa d-icon d-icon-square-full svg-icon svg-node"><use href="#square-full"></use></svg></span><span>function</span></a>&lt;0.92191472/1 in Plug.Session.before_send/2&gt;, <a class="hashtag-cooked" href="/tag/function/1465" data-type="tag" data-slug="function" data-id="1465" data-style-type="icon" data-icon="tag" rel="nofollow"><span class="hashtag-icon-placeholder"><svg class="fa d-icon d-icon-square-full svg-icon svg-node"><use href="#square-full"></use></svg></span><span>function</span></a>&lt;0.40842786/1 in Plug.Telemetry.call/2&gt;, <a class="hashtag-cooked" href="/tag/function/1465" data-type="tag" data-slug="function" data-id="1465" data-style-type="icon" data-icon="tag" rel="nofollow"><span class="hashtag-icon-placeholder"><svg class="fa d-icon d-icon-square-full svg-icon svg-node"><use href="#square-full"></use></svg></span><span>function</span></a>&lt;0.105594227/1 in Phoenix.LiveReloader.before_send_inject_reloader/2&gt;], body_params: %{}, cookies: …</p>
<pre data-code-wrap="elixir"><code class="lang-elixir"></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="156545" 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/pow-custom-controller-doubts/27867/12">Post #11</a>
	                </div>
	            </div>
              <div id="likers-container-156545" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="156545"
                     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="156547" data-post-id="156547">
  <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>To clarify, it works for creating new accounts. What breaks it is creating an account with email &amp; password, logging out and then trying to log in via Oauth using an account tied to that user’s email.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="156547" 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/pow-custom-controller-doubts/27867/13">Post #12</a>
	                </div>
	            </div>
              <div id="likers-container-156547" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="156547"
                     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="156569" data-post-id="156569">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="danschultzer" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/danschultzer/120/4942_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  danschultzer
                  </h3>
		          </div>
						
			          <div class="user-title">
									<span>Pow Core Team</span>
			          </div>
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<aside class="quote no-group" data-username="AlchemistCamp" data-post="12" data-topic="27867">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/alchemistcamp/48/8823_2.png" class="avatar"> AlchemistCamp:</div>
<blockquote>
<p>MyAppWeb.PowAssent.RegistrationView</p>
</blockquote>
</aside>
<p>You have to generate the views and templates for PowAssent, <a href="https://github.com/pow-auth/pow_assent#modified-pow-templates" rel="noopener nofollow ugc">as described in the readme</a>:</p>
<p><code>mix pow_assent.phoenix.gen.templates</code></p>
<p>It’s because you have set <code>web_module: MyAppWeb</code> in your config for Pow.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="156569" 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/pow-custom-controller-doubts/27867/14">Post #13</a>
	                </div>
	            </div>
              <div id="likers-container-156569" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="156569"
                     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="156573" data-post-id="156573">
  <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>Right you are! I must have forgotten that 2nd pow generator when deleting and rebuilding the app in the process of trying to debug it.</p>
<p>Now logging in via ouath is no longer crashing and is asking for a 2nd email address as before. I’ll dig back in in the morning and see if I can figure out what’s causing that behavior and how to override it (since I just want to use the existing email from their Oauth).</p>
<p>Thanks again for all the help!</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="156573" 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/pow-custom-controller-doubts/27867/15">Post #14</a>
	                </div>
	            </div>
              <div id="likers-container-156573" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="156573"
                     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 #14"></div>
  </section>
</div>
    <div class="postbit" id="156575" data-post-id="156575">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="danschultzer" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/danschultzer/120/4942_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  danschultzer
                  </h3>
		          </div>
						
			          <div class="user-title">
									<span>Pow Core Team</span>
			          </div>
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<aside class="quote no-group" data-username="AlchemistCamp" data-post="15" data-topic="27867">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/alchemistcamp/48/8823_2.png" class="avatar"> AlchemistCamp:</div>
<blockquote>
<p>I’ll dig back in in the morning and see if I can figure out what’s causing that behavior and how to override it (since I just want to use the existing email from their Oauth).</p>
</blockquote>
</aside>
<p>It happens when there’s an error on the user id field, both if it has been taken already or if it’s not the right format (though with Github and standard Pow setup that would not happen). Here’s the logic: <a href="https://github.com/pow-auth/pow_assent/blob/v0.4.5/lib/pow_assent/phoenix/controllers/authorization_controller.ex#L129-L133" class="inline-onebox" rel="noopener nofollow ugc">pow_assent/lib/pow_assent/phoenix/controllers/authorization_controller.ex at v0.4.5 · pow-auth/pow_assent · GitHub</a></p>
<p>The context is what sends back the <code>{:error, {:invalid_user_id_field, changeset}}</code> error, as seen here: <a href="https://github.com/pow-auth/pow_assent/blob/v0.4.5/lib/pow_assent/ecto/user_identities/context.ex#L196-L224" class="inline-onebox" rel="noopener nofollow ugc">pow_assent/lib/pow_assent/ecto/user_identities/context.ex at v0.4.5 · pow-auth/pow_assent · GitHub</a></p>
<p>So if you don’t really worry about security implications, you could add a custom <code>create_user/3</code> context method, where after <code>pow_assent_create_user/3</code> returns the above error, you can just look up the user for the email and then call <code>pow_assent_upsert/2</code>.</p>
<p>If you want to instead let users log in first, then you have to set up custom controllers. But as I wrote before, I’ll look into <a href="https://github.com/pow-auth/pow_assent/issues/115" rel="noopener nofollow ugc">that</a> when I got time.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="156575" 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/pow-custom-controller-doubts/27867/16">Post #15</a>
	                </div>
	            </div>
              <div id="likers-container-156575" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="156575"
                     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 #15"></div>
  </section>
</div>
    <div class="postbit" id="156793" data-post-id="156793">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="tenzil" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/tenzil/120/17367_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  tenzil
                    <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><a class="mention" href="/u/danschultzer" rel="nofollow">@danschultzer</a>, I tried both,<br>
The custom context  worked fine, yet i need to add a validation error message on invalid code.<br>
but the custom controllers threw error the following error</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">assign @action not available in eex template.
</code></pre>
<p>I just need to add the action path here. I thought it would be great if you update the doc such that the next person will not face it. or shall i send a PR for this?</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="156793" 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/pow-custom-controller-doubts/27867/17">Post #16</a>
	                </div>
	            </div>
              <div id="likers-container-156793" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="156793"
                     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 #16"></div>
  </section>
</div>
    <div class="postbit" id="156826" data-post-id="156826">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="tenzil" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/tenzil/120/17367_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  tenzil
                    <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>Saw the registration html files, As i generated templates, the url was pointing to <span class="mention">@action</span>, i forgot to update them</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">https://hexdocs.pm/pow/1.0.11/custom_controllers.html#templates
</code></pre>
<p>“Routes.signup_path(<span class="mention">@conn</span>, :create)”</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="156826" 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/pow-custom-controller-doubts/27867/18">Post #17</a>
	                </div>
	            </div>
              <div id="likers-container-156826" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="156826"
                     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 #17"></div>
  </section>
</div>
    <div class="postbit" id="156940" data-post-id="156940">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="tenzil" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/tenzil/120/17367_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  tenzil
                    <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><a class="mention" href="/u/danschultzer" rel="nofollow">@danschultzer</a>, I went with custom controller which helps me to return a valid error message to the user. And i have set the action variable, which worked fine on generated templates.</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">def create(conn, %{"user" =&gt; user_params}) do
    # We'll leverage [`Pow.Plug`](Pow.Plug.html), but you can also follow the classic Phoenix way:
    # user =
    #   %MyApp.Users.User{}
    #   |&gt; MyApp.Users.User.changeset(user_params)
    #   |&gt; MyApp.Repo.insert()

    case MyApp.Users.create_user_using_referral(user_params) do
      {:ok, user} -&gt;
        conn
        |&gt; put_flash(:info, "Welcome, Lets find your spouse!")
        |&gt; redirect(to: Routes.dashboard_path(conn, :index))
      {:invalid_code, changeset} -&gt;
        conn
        |&gt; put_flash(:error, "You have entered an invalid code")
        |&gt; render("new.html", changeset: changeset, action: Routes.registration_path(conn, :create))
      {:error, changeset} -&gt;
        conn
        |&gt; put_flash(:error, "Please correct the errors")
        |&gt; render("new.html", changeset: changeset, action: Routes.registration_path(conn, :create))
    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="156940" 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/pow-custom-controller-doubts/27867/19">Post #18</a>
	                </div>
	            </div>
              <div id="likers-container-156940" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="156940"
                     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 #18"></div>
  </section>
</div>
    <div class="postbit" id="156950" data-post-id="156950">
  <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>What was invovled in setting up a custom controller? Was simply naming a controller <code>MyAppWeb.UserController</code> and overwriting the functions in Pow?</p>
<p>I’m interested in doing this. The primary pain I hit comes from having controller actions hidden in a library and not having control over how possible issues are handled, redirects, error messages, etc.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="156950" 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/pow-custom-controller-doubts/27867/20">Post #19</a>
	                </div>
	            </div>
              <div id="likers-container-156950" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="156950"
                     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 #19"></div>
  </section>
</div>
    <div class="postbit" id="156960" data-post-id="156960">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="tenzil" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/tenzil/120/17367_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  tenzil
                    <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>Yes you can make any controller to overwrite a specific route and its action.</p>
<p>I have overwritten Pow registration controller with just a regular controller. For my understanding , i kind of added made it look alike. When you ran mix pow.phx.gen.templates, it creates a pow/registration/files inside lib/templates. I did the same added pow/registration_controller inside lib/controllers.</p>
<p>Entire Code Block</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">I created a module and named it pow/.
scope "/" do
    pipe_through [:browser]
    resources "/registration", MyAppWeb.Pow.RegistrationController, singleton: true, only: [:create]
  end
</code></pre>
<pre data-code-wrap="elixir"><code class="lang-elixir">controller:
defmodule MyAppWeb.Pow.RegistrationController do
  use MyAppWeb, :controller

  # def new(conn, _params) do
  #   # We'll leverage [`Pow.Plug`](Pow.Plug.html), but you can also follow the classic Phoenix way:
  #   # changeset = MyApp.Users.User.changeset(%MyApp.Users.User{}, %{})

  #   changeset = Pow.Plug.change_user(conn)

  #   render(conn, "new.html", changeset: changeset)
  # end

  def create(conn, %{"user" =&gt; user_params}) do
    # We'll leverage [`Pow.Plug`](Pow.Plug.html), but you can also follow the classic Phoenix way:
    # user =
    #   %MyApp.Users.User{}
    #   |&gt; MyApp.Users.User.changeset(user_params)
    #   |&gt; MyApp.Repo.insert()

    case MyApp.Users.create_user_using_referral(user_params) do
      {:ok, user} -&gt;
        conn
        |&gt; put_flash(:info, "Welcome, Lets find your spouse!")
        |&gt; redirect(to: Routes.dashboard_path(conn, :index))
      {:invalid_code, changeset} -&gt;
        conn
        |&gt; put_flash(:error, "You have entered an invalid code")
        |&gt; render("new.html", changeset: changeset, action: Routes.registration_path(conn, :create))
      {:error, changeset} -&gt;
        conn
        |&gt; put_flash(:error, "Please correct the errors")
        |&gt; render("new.html", changeset: changeset, action: Routes.registration_path(conn, :create))
    end
  end
end
</code></pre>
<p>And i used pow custom context as well.</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">defmodule MyApp.Users do
   use Pow.Ecto.Context,
        repo: MyApp.Repo,
       user: MyApp.Users.User

  def create_user_using_referral(params) do
    case params["referral_code"] do
      nil -&gt; pow_create(params)
      "" -&gt; pow_create(params)
      code -&gt;
        case MyApp.Trial.get_by_referral_code(code) do
          nil -&gt;
            changeset = User.changeset(%User{}, params)
            Ecto.Changeset.add_error(changeset, :referral_code, "Entered code is invalid", validation: :invalid)
            {:invalid_code, changeset}
          referral_code -&gt;
            pow_create(params)
        end
    end
  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="156960" 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/pow-custom-controller-doubts/27867/21">Post #20</a>
	                </div>
	            </div>
              <div id="likers-container-156960" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="156960"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-most-liked cat-most-liked" title="One of the top 3 liked posts in this thread!"></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/27867/load_more?page=3">Load more posts (8 remaining)</a>
</div></template></turbo-stream>