Commit 9c07e61b authored by James Laver's avatar James Laver

Merge branch 'fix/password-reset-urls' into 'develop'

Make transactional emails use correct urls pointing to the frontend

See merge request moodlenet/servers/federated!21
parents 0886e915 d6f031c0
Pipeline #66741382 passed with stages
in 8 minutes and 31 seconds
......@@ -85,4 +85,4 @@ config :moodle_net, MoodleNet.Repo,
config :moodle_net, :ap_base_url,
(System.get_env("AP_BASE_URL") || "http://dev.localhost:4000/activity_pub")
config :moodle_net, :frontend_base_url,
(System.get_env("FRONTEND_BASE_URL") || "http:/localhost:3000/")
(System.get_env("FRONTEND_BASE_URL") || "http://localhost:3000/")
......@@ -29,3 +29,5 @@ config :moodle_net, MoodleNet.Mailer,
adapter: Bamboo.TestAdapter
config :moodle_net, :ap_base_url, "http://test.localhost:4001/activity_pub"
config :moodle_net, :frontend_base_url,
(System.get_env("FRONTEND_BASE_URL") || "http://localhost:3000/")
......@@ -8,7 +8,7 @@ defmodule MoodleNet.Email do
use Bamboo.Phoenix, view: MoodleNetWeb.EmailView
def welcome(user, token) do
url = email_confirmation_url(token)
url = email_confirmation_url(user.id, token)
base_email(user)
|> subject(gettext("Welcome to MoodleNet"))
|> render(:welcome, user: user, url: url)
......@@ -37,15 +37,14 @@ defmodule MoodleNet.Email do
|> put_layout({MoodleNetWeb.LayoutView, :email})
end
defp email_confirmation_url(token) do
MoodleNetWeb.Endpoint.struct_url()
|> Map.put(:path, "/email_confirmation?token=#{token}")
|> URI.to_string()
end
defp email_confirmation_url(id, token),
do: frontend_url("/confirm-email/#{token}")
defp reset_password_url(token), do: frontend_url("reset/#{token}")
defp reset_password_url(token) do
MoodleNetWeb.Endpoint.struct_url()
|> Map.put(:path, "/reset/#{token}")
|> URI.to_string()
# Note that the base url is expected to end with a slash (/)
defp frontend_url(path) do
Application.fetch_env!(:moodle_net, :frontend_base_url) <> path
end
end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment