<turbo-stream action="append" target="posts_list"><template>    <div class="postbit" id="157027" data-post-id="157027">
  <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="20" 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>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>
</blockquote>
</aside>
<p>You can both customize <a href="https://github.com/danschultzer/pow#i18n" rel="noopener nofollow ugc">messages</a> and <a href="https://github.com/danschultzer/pow#callback-routes" rel="noopener nofollow ugc">redirect paths</a>. The <code>conn</code> is passed along so you could even add some conditional based on, e.g. the <code>@changeset</code> assign for the message or route.</p>
<p>But the way <a class="mention" href="/u/tenzil" rel="nofollow">@tenzil</a> resolved it is what I prefer since it’s much more explicit, and it makes sense when you e.g. add controller test to it. One idea I have of Pow is that in most cases it should work more as a helper than a framework, so whenever you customize stuff you basically write it all out so it’s easy to test, understand and take control of rather than depending on the library.</p>
<p>I definitely want to ease these steps so please do let me know what could be improved!</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="157027" 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/22">Post #21</a>
	                </div>
	            </div>
              <div id="likers-container-157027" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="157027"
                     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>
    <div class="postbit" id="157372" data-post-id="157372">
  <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">
								<aside class="quote no-group" data-username="tenzil" data-post="21" 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/tenzil/48/17367_2.png" class="avatar"> tenzil:</div>
<blockquote>
<p>create_user_using_referral</p>
</blockquote>
</aside>
<p><a class="mention" href="/u/danschultzer" rel="nofollow">@danschultzer</a>, as i was creating user with pow_create(params), I am not able to signin the user after registration. How to signup the user after this? I am going to try with sync user function.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="157372" 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/23">Post #22</a>
	                </div>
	            </div>
              <div id="likers-container-157372" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="157372"
                     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 #22"></div>
  </section>
</div>
    <div class="postbit" id="157375" data-post-id="157375">
  <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>Sync user function worked!</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">defmodule MyAppWeb.Pow.User do
  @spec sync_user(Plug.Conn.t(), map()) :: Plug.Conn.t()
  def sync_user(conn, user) do
    config = Pow.Plug.fetch_config(conn)
    plug   = Pow.Plug.get_plug(config)

    plug.do_create(conn, user, config)
  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="157375" 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/24">Post #23</a>
	                </div>
	            </div>
              <div id="likers-container-157375" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="157375"
                     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 #23"></div>
  </section>
</div>
    <div class="postbit" id="170953" data-post-id="170953">
  <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>Hi <a class="mention" href="/u/danschultzer" rel="nofollow">@danschultzer</a>, hope you are doing well. My custom registration controller is working fine, with and without referral codes. Now the thing is, i added few extensions  “reset password and confirmation with emails”. The setup is working fine for reset password. but it didn’t for confirmation. I googled and found out this link <a href="https://github.com/danschultzer/pow/blob/6518aaad2f1cbb680ac8ff8e8760021f00011717/lib/extensions/email_confirmation/phoenix/controllers/controller_callbacks.ex#L53-L60" class="inline-onebox" rel="noopener nofollow ugc">pow/lib/extensions/email_confirmation/phoenix/controllers/controller_callbacks.ex at 6518aaad2f1cbb680ac8ff8e8760021f00011717 · pow-auth/pow · GitHub</a><br>
and added this function. It worked fine. I send the email as well.</p>
<p>But the issue is, when i click the link. its not confirming the account, its throwing “Email couldn’t be confirmed”</p>
<p>The expectation is, I need to register a unconfirmed account and send a confirmation email using which user can access the website.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="170953" 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/25">Post #24</a>
	                </div>
	            </div>
              <div id="likers-container-170953" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="170953"
                     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 #24"></div>
  </section>
</div>
    <div class="postbit" id="170954" data-post-id="170954">
  <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">
								<p>It has changed since then: <a href="https://github.com/danschultzer/pow/blob/v1.0.19/lib/extensions/email_confirmation/phoenix/controllers/controller_callbacks.ex#L127-L140" class="inline-onebox" rel="noopener nofollow ugc">pow/lib/extensions/email_confirmation/phoenix/controllers/controller_callbacks.ex at v1.0.19 · pow-auth/pow · GitHub</a></p>
<p>If you use <code>1.0.19</code> and up, then all tokens need to be signed before they can be used.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="170954" 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/26">Post #25</a>
	                </div>
	            </div>
              <div id="likers-container-170954" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="170954"
                     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 #25"></div>
  </section>
</div>
    <div class="postbit" id="170955" data-post-id="170955">
  <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>Thank you <a class="mention" href="/u/danschultzer" rel="nofollow">@danschultzer</a>  for the quick response.</p>
<p>Yes, i recently updated it, like 2 days ago.</p>
<p>I updated few lines to get it work for me.</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">@spec send_confirmation_email(map(), Conn.t()) :: any()
  def send_confirmation_email(user, conn) do
    url               = confirmation_url(conn, user)
    unconfirmed_user  = %{user | email: user.unconfirmed_email || user.email}
    email             = Mailer.email_confirmation(conn, unconfirmed_user, url)

    Pow.Phoenix.Mailer.deliver(conn, email)
  end

  defp confirmation_url(conn, user) do
    token = PowEmailConfirmation.Plug.sign_confirmation_token(conn, user)
    ConfirmationController.routes(conn).url_for(conn, ConfirmationController, :show, [token])
  end
</code></pre>
<p>Now i got “The email address has been confirmed” and got redirected to registration edit page.<br>
How to register/signup an  unconfirmed email, and redirect to a different/custom url post confirmation.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="170955" 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/27">Post #26</a>
	                </div>
	            </div>
              <div id="likers-container-170955" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="170955"
                     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 #26"></div>
  </section>
</div>
    <div class="postbit" id="170957" data-post-id="170957">
  <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="tenzil" data-post="27" 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/tenzil/48/17367_2.png" class="avatar"> tenzil:</div>
<blockquote>
<p>How to register/signup an unconfirmed email, and redirect to a different/custom url post confirmation.</p>
</blockquote>
</aside>
<p>You would need to add a custom controller action for that. The logic is super simple though: <a href="https://github.com/danschultzer/pow/blob/v1.0.19/lib/extensions/email_confirmation/phoenix/controllers/confirmation_controller.ex" class="inline-onebox" rel="noopener nofollow ugc">pow/lib/extensions/email_confirmation/phoenix/controllers/confirmation_controller.ex at v1.0.19 · pow-auth/pow · GitHub</a></p>
<p>You just have to load the user by the token with <code>PowEmailConfirmation.Plug.load_user_by_token/2</code> and then call <code>PowEmailConfirmation.Plug.Plug.confirm_email/2</code> to confirm it.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="170957" 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/28">Post #27</a>
	                </div>
	            </div>
              <div id="likers-container-170957" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="170957"
                     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 #27"></div>
  </section>
</div>
    <div class="postbit" id="171144" data-post-id="171144">
  <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>Hi <a class="mention" href="/u/danschultzer" rel="nofollow">@danschultzer</a>, i gone through the code. Looks like unconfirmed_email carries nil value on user creation in my custom registration controller. So i added a check to update unconfirmed_email.<br>
Now its working as expected. After registration, confirmation link is sent. post clicking the confirmation link, the account is confirmed.</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">def changeset(user_or_changeset, attrs) do
    user_or_changeset
    |&gt; pow_changeset(attrs)
    |&gt; pow_extension_changeset(attrs)
    |&gt; Ecto.Changeset.validate_required([:fname, :lname, :dob, :gender])
    |&gt; set_age()
    |&gt; unconfirm_email
  end

  defp unconfirm_email(%Ecto.Changeset{valid?: true, changes: %{email: email}} = changeset) do
    put_change(changeset, :unconfirmed_email, email)
  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="171144" 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/29">Post #28</a>
	                </div>
	            </div>
              <div id="likers-container-171144" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="171144"
                     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>