changeset 1404:6a35167a4e2c

pages (login, register): fix `allow_registration`: if `allow_registration` is false: - `register_url` is not set in login page - register page returns HTTP_FORBIDDEN
author Goffi <goffi@goffi.org>
date Fri, 16 Apr 2021 18:38:45 +0200
parents 1357d04107d1
children 3dff555fe691
files libervia/pages/login/page_meta.py libervia/pages/register/page_meta.py
diffstat 2 files changed, 4 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/libervia/pages/login/page_meta.py	Sat Mar 27 15:23:49 2021 +0100
+++ b/libervia/pages/login/page_meta.py	Fri Apr 16 18:38:45 2021 +0200
@@ -36,7 +36,8 @@
     )
 
     # register page url
-    template_data["register_url"] = self.getPageRedirectURL(request, "register")
+    if self.host.options["allow_registration"]:
+        template_data["register_url"] = self.getPageRedirectURL(request, "register")
 
     #  if login is set, we put it in template to prefill field
     template_data["login"] = session_data.popPageData(self, "login")
--- a/libervia/pages/register/page_meta.py	Sat Mar 27 15:23:49 2021 +0100
+++ b/libervia/pages/register/page_meta.py	Fri Apr 16 18:38:45 2021 +0200
@@ -16,6 +16,8 @@
 
 
 def prepare_render(self, request):
+    if not self.host.options["allow_registration"]:
+        self.pageError(request, C.HTTP_FORBIDDEN)
     profile = self.getProfile(request)
     if profile is not None:
         self.pageRedirect("/login/logged", request)