From af53f14879b624063eaee7220abe314a84cdc261 Mon Sep 17 00:00:00 2001
From: Alex Lion
- {gettext("By creating an account, you agree to our")} - {" "} - {link(gettext("Terms of Service"), - to: ~p"/tos", - class: - "text-gray-300 underline decoration-gray-500 underline-offset-2 hover:text-white" - )} - {" "} - {gettext("and")} - {" "} - {link(gettext("Privacy Policy"), - to: ~p"/privacy", - class: - "text-gray-300 underline decoration-gray-500 underline-offset-2 hover:text-white" - )} . -
+ <% terms_url = Application.get_env(:claper, :terms_url) %> + <% privacy_url = Application.get_env(:claper, :privacy_url) %> + <%= if terms_url && privacy_url do %> ++ {gettext("By creating an account, you agree to our")} + {" "} + {link(gettext("Terms of Service"), + to: terms_url, + target: "_blank", + rel: "noopener noreferrer", + class: + "text-gray-300 underline decoration-gray-500 underline-offset-2 hover:text-white" + )} + {" "} + {gettext("and")} + {" "} + {link(gettext("Privacy Policy"), + to: privacy_url, + target: "_blank", + rel: "noopener noreferrer", + class: + "text-gray-300 underline decoration-gray-500 underline-offset-2 hover:text-white" + )} . +
+ <% end %> diff --git a/lib/claper_web/templates/user_reset_password/edit.html.heex b/lib/claper_web/templates/user_reset_password/edit.html.heex index c972129..b2bb4b7 100644 --- a/lib/claper_web/templates/user_reset_password/edit.html.heex +++ b/lib/claper_web/templates/user_reset_password/edit.html.heex @@ -18,9 +18,7 @@ {gettext("Pick a new password and get back to presenting.")}- {gettext( - "Choose something secure that you'll remember, then you're all set." - )} + {gettext("Choose something secure that you'll remember, then you're all set.")}
diff --git a/test/claper_web/controllers/user_registration_controller_test.exs b/test/claper_web/controllers/user_registration_controller_test.exs index e7f47a8..c656030 100644 --- a/test/claper_web/controllers/user_registration_controller_test.exs +++ b/test/claper_web/controllers/user_registration_controller_test.exs @@ -8,10 +8,14 @@ defmodule ClaperWeb.UserRegistrationControllerTest do setup do enable_account_creation = Application.get_env(:claper, :enable_account_creation) email_confirmation = Application.get_env(:claper, :email_confirmation) + terms_url = Application.get_env(:claper, :terms_url) + privacy_url = Application.get_env(:claper, :privacy_url) on_exit(fn -> Application.put_env(:claper, :enable_account_creation, enable_account_creation) Application.put_env(:claper, :email_confirmation, email_confirmation) + Application.put_env(:claper, :terms_url, terms_url) + Application.put_env(:claper, :privacy_url, privacy_url) end) :ok @@ -48,6 +52,56 @@ defmodule ClaperWeb.UserRegistrationControllerTest do assert redirected_to(conn) == "/events" end + + test "shows the legal notice when both TERMS_URL and PRIVACY_URL are configured", %{ + conn: conn + } do + Application.put_env(:claper, :enable_account_creation, true) + Application.put_env(:claper, :terms_url, "https://example.com/terms") + Application.put_env(:claper, :privacy_url, "https://example.com/privacy") + + conn = get(conn, ~p"/users/register") + response = html_response(conn, 200) + + assert response =~ "By creating an account" + assert response =~ "https://example.com/terms" + assert response =~ "https://example.com/privacy" + end + + test "hides the legal notice when only TERMS_URL is configured", %{conn: conn} do + Application.put_env(:claper, :enable_account_creation, true) + Application.put_env(:claper, :terms_url, "https://example.com/terms") + Application.put_env(:claper, :privacy_url, nil) + + conn = get(conn, ~p"/users/register") + response = html_response(conn, 200) + + refute response =~ "By creating an account" + refute response =~ "https://example.com/terms" + end + + test "hides the legal notice when only PRIVACY_URL is configured", %{conn: conn} do + Application.put_env(:claper, :enable_account_creation, true) + Application.put_env(:claper, :terms_url, nil) + Application.put_env(:claper, :privacy_url, "https://example.com/privacy") + + conn = get(conn, ~p"/users/register") + response = html_response(conn, 200) + + refute response =~ "By creating an account" + refute response =~ "https://example.com/privacy" + end + + test "hides the legal notice when neither URL is configured", %{conn: conn} do + Application.put_env(:claper, :enable_account_creation, true) + Application.put_env(:claper, :terms_url, nil) + Application.put_env(:claper, :privacy_url, nil) + + conn = get(conn, ~p"/users/register") + response = html_response(conn, 200) + + refute response =~ "By creating an account" + end end describe "POST /users/register" do