comparison libervia/server/pages.py @ 1405:3dff555fe691

pages: do no send HTTP_FORBIDDEN when registration is not allowed and no profile is connected: if registration is not allowed, an existing user may still want to log in.
author Goffi <goffi@goffi.org>
date Fri, 16 Apr 2021 18:40:17 +0200
parents 822bd0139769
children 80683be8d341
comparison
equal deleted inserted replaced
1404:6a35167a4e2c 1405:3dff555fe691
1666 if self.access == C.PAGES_ACCESS_PUBLIC: 1666 if self.access == C.PAGES_ACCESS_PUBLIC:
1667 pass 1667 pass
1668 elif self.access == C.PAGES_ACCESS_PROFILE: 1668 elif self.access == C.PAGES_ACCESS_PROFILE:
1669 profile = self.getProfile(request) 1669 profile = self.getProfile(request)
1670 if not profile: 1670 if not profile:
1671 # no session started 1671 # registration allowed, we redirect to login page
1672 if not self.host.options["allow_registration"]: 1672 login_url = self.getPageRedirectURL(request)
1673 # registration not allowed, access is not granted 1673 self.HTTPRedirect(request, login_url)
1674 self.pageError(request, C.HTTP_FORBIDDEN)
1675 else:
1676 # registration allowed, we redirect to login page
1677 login_url = self.getPageRedirectURL(request)
1678 self.HTTPRedirect(request, login_url)
1679 1674
1680 def setBestLocale(self, request): 1675 def setBestLocale(self, request):
1681 """Guess the best locale when it is not specified explicitly by user 1676 """Guess the best locale when it is not specified explicitly by user
1682 1677
1683 This method will check "accept-language" header, and set locale to first 1678 This method will check "accept-language" header, and set locale to first