bones73k/lib/bones73k_web/controllers/user_settings_controller.ex

20 lines
571 B
Elixir
Raw Normal View History

2021-02-24 07:49:39 -05:00
defmodule Bones73kWeb.UserSettingsController do
use Bones73kWeb, :controller
2021-02-24 07:49:39 -05:00
alias Bones73k.Accounts
def confirm_email(conn, %{"token" => token}) do
case Accounts.update_user_email(conn.assigns.current_user, token) do
:ok ->
conn
|> put_flash(:info, "Email changed successfully.")
|> redirect(to: Routes.user_settings_path(conn, :edit))
:error ->
conn
|> put_flash(:error, "Email change link is invalid or it has expired.")
|> redirect(to: Routes.user_settings_path(conn, :edit))
end
end
end