mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-09-19 04:59:01 +00:00
improved my bugfix :>
This commit is contained in:
parent
cde5f25239
commit
5b88015a28
@ -12,18 +12,18 @@ LOGGER = logging.getLogger(__name__)
|
|||||||
class FirstBootMiddleware:
|
class FirstBootMiddleware:
|
||||||
""" Forward to firstboot page if firstboot isn't finished yet """
|
""" Forward to firstboot page if firstboot isn't finished yet """
|
||||||
def process_request(self, request):
|
def process_request(self, request):
|
||||||
with sqlite_db(cfg.store_file, table='firstboot') as database:
|
# TODO: there should be a better way to tell if we're at the
|
||||||
first_boot_url = reverse('first_boot:index')
|
# firstboot module
|
||||||
if not 'state' in database:
|
if "firstboot" not in request.path:
|
||||||
if hasattr(request, 'url') and request.url != first_boot_url:
|
with sqlite_db(cfg.store_file, table='firstboot') as database:
|
||||||
|
first_boot_url = reverse('first_boot:index')
|
||||||
|
if 'state' not in database:
|
||||||
# Permanent redirect causes the browser to cache the
|
# Permanent redirect causes the browser to cache the
|
||||||
# redirect, preventing the user from navigating to /plinth
|
# redirect, preventing the user from navigating to /plinth
|
||||||
# until the browser is restarted.
|
# until the browser is restarted.
|
||||||
return HttpResponseRedirect(first_boot_url)
|
return HttpResponseRedirect(first_boot_url)
|
||||||
else:
|
|
||||||
return
|
|
||||||
|
|
||||||
if database['state'] < 5:
|
elif database['state'] < 5:
|
||||||
LOGGER.info('First boot state - %d', database['state'])
|
LOGGER.info('First boot state - %d', database['state'])
|
||||||
return HttpResponseRedirect(reverse('first_boot:state%d' %
|
return HttpResponseRedirect(reverse('first_boot:state%d' %
|
||||||
database['state']))
|
database['state']))
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user