diff options
author | Roald de Vries <rdevries@thoughtworks.com> | 2016-11-30 10:29:27 +0100 |
---|---|---|
committer | Roald de Vries <rdevries@thoughtworks.com> | 2016-11-30 10:29:27 +0100 |
commit | c10c6fb76f06e0cfc6f061a1bd9df14d689fb176 (patch) | |
tree | 91d7abe45c7ac46fc5b8364d1449366708a2ea12 /service/pixelated | |
parent | 54600b0454809eeed12b01960a1d0ecaeb0d86a9 (diff) |
redirect to login from root url when not logged in
Diffstat (limited to 'service/pixelated')
-rw-r--r-- | service/pixelated/resources/root_resource.py | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/service/pixelated/resources/root_resource.py b/service/pixelated/resources/root_resource.py index 24d097f9..035d5f18 100644 --- a/service/pixelated/resources/root_resource.py +++ b/service/pixelated/resources/root_resource.py @@ -35,6 +35,7 @@ from pixelated.resources.keys_resource import KeysResource from pixelated.resources.inbox_resource import InboxResource, MODE_STARTUP, MODE_RUNNING from twisted.web.resource import NoResource from twisted.web.static import File +from twisted.web.util import Redirect from twisted.logger import Logger @@ -45,11 +46,17 @@ class PublicRootResource(BaseResource): def __init__(self, services_factory): BaseResource.__init__(self, services_factory) + self._redirect_to_inbox_resource = Redirect('login') def initialize(self, provider=None, disclaimer_banner=None, authenticator=None): self.putChild(LoginResource.BASE_URL, LoginResource(self._services_factory, provider, disclaimer_banner=disclaimer_banner, authenticator=authenticator)) + def getChildWithDefault(self, path, request): + if path == '': + return self._redirect_to_inbox_resource + return BaseResource.getChildWithDefault(self, path, request) + class RootResource(PublicRootResource): |