From 2287c65784a38728bfaf72ead2973683a2ee9a72 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Thu, 17 Jan 2019 17:55:24 +0100 Subject: [PATCH] forcelogin: ui_render sorting key of 0 If third party UIPlugin want to override the forcelogin plugin, they'll need to return a negative sorting key. --- src/octoprint/plugins/forcelogin/__init__.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/octoprint/plugins/forcelogin/__init__.py b/src/octoprint/plugins/forcelogin/__init__.py index 8e6914a55..ceee6d608 100644 --- a/src/octoprint/plugins/forcelogin/__init__.py +++ b/src/octoprint/plugins/forcelogin/__init__.py @@ -103,6 +103,14 @@ class ForceLoginPlugin(octoprint.plugin.UiPlugin, def get_ui_preemptive_caching_enabled(self): return False + def get_sorting_key(self, context=None): + if context == "UiPlugin.on_ui_render": + # If a plugin *really* wants to come before this plugin, it'll have to turn to negative numbers. + # + # This is obviously discouraged for security reasons, but very specific setups might make it necessary, + # so we make it possible. If this should get abused long term we can always turn this into -inf. + return 0 + def get_before_request_handlers(self): def check_login_required(): if self._user_manager.enabled and not self._user_manager.hasBeenCustomized():