fix: prefer wuttaweb config for "home redirect to login" feature

This commit is contained in:
Lance Edgar 2024-08-20 22:16:01 -05:00
parent 1def26a35b
commit b6a8e508bf

View file

@ -25,6 +25,7 @@ Various common views
"""
import os
import warnings
from collections import OrderedDict
from rattail.batch import consume_batch_id
@ -50,9 +51,21 @@ class CommonView(View):
Home page view.
"""
app = self.get_rattail_app()
# maybe auto-redirect anons to login
if not self.request.user:
if self.rattail_config.getbool('tailbone', 'login_is_home', default=True):
raise self.redirect(self.request.route_url('login'))
redirect = self.config.get_bool('wuttaweb.home_redirect_to_login')
if redirect is None:
redirect = self.config.get_bool('tailbone.login_is_home')
if redirect is not None:
warnings.warn("tailbone.login_is_home setting is deprecated; "
"please set wuttaweb.home_redirect_to_login instead",
DeprecationWarning)
else:
# TODO: this is opposite of upstream default, should change
redirect = True
if redirect:
return self.redirect(self.request.route_url('login'))
image_url = self.rattail_config.get(
'tailbone', 'main_image_url',