Commit faefa9d1 authored by echel0n's avatar echel0n
Browse files

Fixed issues with custom web roots and redirects

Checking for updates now redirects back to referrer url
parent bd35aae6
# Changelog
- * 14a6a56 - 2018-08-23: Pre-Release v9.3.58.dev2
- * c27cc36 - 2018-08-23: Fixed issues with custom web roots and redirects Checking for updates now redirects back to referrer url
- * bd35aae - 2018-08-23: Pre-Release v9.3.58.dev2
- * 45d0b32 - 2018-08-23: Switch TorrentLeech provider to login via cookies due to reCAPTCHA
- * 2f40c76 - 2018-08-22: Pre-Release v9.3.58.dev1
- * 9010755 - 2018-08-22: Fixed issue #256 - unable to search BTN
......
......@@ -109,14 +109,10 @@ class WebServer(object):
# api
(r'%s(/?.*)' % self.api_root, ApiHandler),
# redirect to web root to home
# redirect to home
(r"(%s)" % sickrage.app.config.web_root, RedirectHandler,
{"url": "%s/home" % sickrage.app.config.web_root}),
# redirect to add in missing web root
(r"(?!%s)/(.*)" % sickrage.app.config.web_root, RedirectHandler,
{"url": "%s/{0}" % sickrage.app.config.web_root}),
# api key
(r'%s/getkey(/?.*)' % sickrage.app.config.web_root, KeyHandler),
......
......@@ -27,6 +27,7 @@ import time
import traceback
import urllib
from collections import OrderedDict
from urlparse import urlparse
import dateutil.tz
import markdown2
......@@ -212,6 +213,15 @@ class BaseHandler(RequestHandler):
self.set_header('Access-Control-Allow-Methods', 'POST, GET, OPTIONS')
self.set_header('Cache-Control', 'max-age=0,no-cache,no-store')
def redirect(self, url, permanent=True, status=None):
m = re.search(r'(?!%s)/(.*)' % sickrage.app.config.web_root, url)
if m: url = "{}/{}".format(sickrage.app.config.web_root, m.group(0).lstrip('/'))
super(BaseHandler, self).redirect(url, permanent, status)
def previous_url(self):
url = urlparse(self.request.headers.get("referer", "/{}/".format(sickrage.app.config.default_page)))
return url._replace(scheme="", netloc="").geturl()
class WebHandler(BaseHandler):
def __init__(self, *args, **kwargs):
......@@ -1032,7 +1042,7 @@ class Home(WebHandler):
topmenu="system",
controller='home',
action="restart",
)# if not force else 'SiCKRAGE is now restarting, please wait a minute then manually go back to the main page'
) # if not force else 'SiCKRAGE is now restarting, please wait a minute then manually go back to the main page'
def updateCheck(self, pid=None):
if str(pid) != str(sickrage.app.pid):
......@@ -1042,7 +1052,7 @@ class Home(WebHandler):
if not sickrage.app.version_updater.check_for_new_version(True):
sickrage.app.alerts.message(_('No new updates!'))
return self.redirect("/{}/".format(sickrage.app.config.default_page))
return self.redirect(self.previous_url())
def update(self, pid=None):
if str(pid) != str(sickrage.app.pid):
......@@ -1054,7 +1064,7 @@ class Home(WebHandler):
else:
self._genericMessage(_("Update Failed"),
_("Update wasn't successful, not restarting. Check your log for more information."))
return self.redirect("/{}/".format(sickrage.app.config.default_page))
return self.redirect(self.previous_url())
def verifyPath(self, path):
if os.path.isfile(path):
......@@ -1069,7 +1079,7 @@ class Home(WebHandler):
else:
sickrage.app.alerts.message(_('Installed SiCKRAGE requirements successfully!'))
return self.redirect("/{}/".format(sickrage.app.config.default_page))
return self.redirect(self.previous_url())
def branchCheckout(self, branch):
if branch and sickrage.app.version_updater.updater.current_branch != branch:
......@@ -1080,7 +1090,7 @@ class Home(WebHandler):
else:
sickrage.app.alerts.message(_('Already on branch: '), branch)
return self.redirect("/{}/".format(sickrage.app.config.default_page))
return self.redirect(self.previous_url())
def displayShow(self, show=None):
if show is None:
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment