diff --git a/config.dist.yaml b/config.dist.yaml index f6f5fc6..3e9e740 100644 --- a/config.dist.yaml +++ b/config.dist.yaml @@ -15,3 +15,6 @@ admin: trust_proxy: false auto_join: - "!your_room_id:your.server" +legal: + - title: "Terms of Service" + url: "https://matrix.your.server/_matrix/consent" diff --git a/src/synapse_registration/registration/templates/registration/complete_registration.html b/src/synapse_registration/registration/templates/registration/complete_registration.html index 08f799e..a5f87c0 100644 --- a/src/synapse_registration/registration/templates/registration/complete_registration.html +++ b/src/synapse_registration/registration/templates/registration/complete_registration.html @@ -24,6 +24,16 @@

Sending this form will create a Matrix account for you and reserve your username. However, you will not be able to log in until an administrator approves your registration. Please provide a reason for your registration to help us expedite the approval process.

+ {% if legal_links %} +

+ By completing this registration, you agree to the following: +

+

+ {% endif %} {% endblock content %} diff --git a/src/synapse_registration/registration/templates/registration/email_form.html b/src/synapse_registration/registration/templates/registration/email_form.html index 26b32bb..fae0ebb 100644 --- a/src/synapse_registration/registration/templates/registration/email_form.html +++ b/src/synapse_registration/registration/templates/registration/email_form.html @@ -16,6 +16,14 @@

By clicking the button below, you agree that we store your email address and the IP address of the device you are using to send this request for processing your registration.

+ {% if legal_links %} +

+ You also confirm that you have read and agree to the following documents, which govern the use of our Matrix server: + {% for link in legal_links %} + {{ link.title }}{% if not forloop.last %}, {% endif %} + {% endfor %} +

+ {% endif %} {% endblock content %} diff --git a/src/synapse_registration/registration/views.py b/src/synapse_registration/registration/views.py index 80c48be..21f4034 100644 --- a/src/synapse_registration/registration/views.py +++ b/src/synapse_registration/registration/views.py @@ -45,6 +45,11 @@ class EmailInputView(FormView): template_name = "registration/email_form.html" form_class = EmailForm + def get_context_data(self, **kwargs): + context = super().get_context_data(**kwargs) + context["legal_links"] = settings.LEGAL_LINKS + return context + def form_valid(self, form): email = form.cleaned_data["email"] @@ -114,6 +119,11 @@ class CompleteRegistrationView(FormView): form_class = RegistrationForm success_url = reverse_lazy("registration_complete") + def get_context_data(self, **kwargs): + context = super().get_context_data(**kwargs) + context["legal_links"] = settings.LEGAL_LINKS + return context + def form_valid(self, form): password = form.cleaned_data["password1"] registration_reason = form.cleaned_data["registration_reason"] diff --git a/src/synapse_registration/synapse_registration/settings.py b/src/synapse_registration/synapse_registration/settings.py index bebf647..ddbf3ac 100644 --- a/src/synapse_registration/synapse_registration/settings.py +++ b/src/synapse_registration/synapse_registration/settings.py @@ -54,6 +54,7 @@ if not ALLOWED_HOSTS: CSRF_TRUSTED_ORIGINS = [f"https://{host}" for host in ALLOWED_HOSTS] +LEGAL_LINKS = config.get("legal", []) # Synapse configuration