From cde5f2523987e61032537125ba2357630ac11958 Mon Sep 17 00:00:00 2001 From: fonfon Date: Tue, 29 Jul 2014 17:05:29 +0300 Subject: [PATCH] bugfix: no more circular redirects to /firstboot --- modules/first_boot/middleware.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/modules/first_boot/middleware.py b/modules/first_boot/middleware.py index 3d354b1ea..d28967d42 100644 --- a/modules/first_boot/middleware.py +++ b/modules/first_boot/middleware.py @@ -13,11 +13,15 @@ class FirstBootMiddleware: """ Forward to firstboot page if firstboot isn't finished yet """ def process_request(self, request): with sqlite_db(cfg.store_file, table='firstboot') as database: + first_boot_url = reverse('first_boot:index') if not 'state' in database: - # Permanent redirect causes the browser to cache the redirect, - # preventing the user from navigating to /plinth until the - # browser is restarted. - return HttpResponseRedirect(reverse('first_boot:index')) + if hasattr(request, 'url') and request.url != first_boot_url: + # Permanent redirect causes the browser to cache the + # redirect, preventing the user from navigating to /plinth + # until the browser is restarted. + return HttpResponseRedirect(first_boot_url) + else: + return if database['state'] < 5: LOGGER.info('First boot state - %d', database['state'])