2021-03-05 19:23:32 -05:00
|
|
|
defmodule Shift73kWeb.UserSettingsController do
|
|
|
|
use Shift73kWeb, :controller
|
2020-09-12 20:07:02 -04:00
|
|
|
|
2021-03-05 19:23:32 -05:00
|
|
|
alias Shift73k.Accounts
|
2020-09-12 20:07:02 -04:00
|
|
|
|
|
|
|
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
|