Esempio n. 1
0
	def will_handle_ui(self, request):
		if not self.active:
			# not active, not responsible
			return False

		from octoprint.server.util import loginUserFromApiKey, loginUserFromAuthorizationHeader, InvalidApiKeyException
		from octoprint.server.util.flask import passive_login

		# first try to login via api key & authorization header, just in case that's set
		try:
			if loginUserFromApiKey():
				# successful? No need for handling the UI
				return False
		except InvalidApiKeyException:
			pass # ignored

		if loginUserFromAuthorizationHeader():
			# successful? No need for handling the UI
			return False

		# then try a passive login
		result = passive_login()
		if hasattr(result, "status_code") and result.status_code == 200:
			# successful? No need for handling the UI
			return False
		else:
			return True
Esempio n. 2
0
    def will_handle_ui(self, request):
        if not self.active:
            # not active, not responsible
            return False

        from octoprint.server.util import loginUserFromApiKey, loginUserFromAuthorizationHeader, InvalidApiKeyException
        from octoprint.server.util.flask import passive_login

        # first try to login via api key & authorization header, just in case that's set
        try:
            if loginUserFromApiKey():
                # successful? No need for handling the UI
                return False
        except InvalidApiKeyException:
            pass  # ignored

        if loginUserFromAuthorizationHeader():
            # successful? No need for handling the UI
            return False

        # then try a passive login
        passive_login()
        if Permissions.STATUS.can() and Permissions.SETTINGS_READ.can():
            # Status & settings_read permission? No need to handle UI
            return False
        else:
            return True
Esempio n. 3
0
    def will_handle_ui(self, request):
        if not self.active:
            # not active, not responsible
            return False

        from octoprint.server.util import loginUserFromApiKey, loginUserFromAuthorizationHeader, InvalidApiKeyException
        from octoprint.server.util.flask import passive_login

        # first try to login via api key & authorization header, just in case that's set
        try:
            if loginUserFromApiKey():
                # successful? No need for handling the UI
                return False
        except InvalidApiKeyException:
            pass  # ignored

        if loginUserFromAuthorizationHeader():
            # successful? No need for handling the UI
            return False

        # then try a passive login
        result = passive_login()
        if hasattr(result, "status_code") and result.status_code == 200:
            # successful? No need for handling the UI
            return False
        else:
            return True