Use a namedtuple for authentication prompts.
This commit is contained in:
parent
842c69dfdd
commit
024549e3b0
@ -248,9 +248,8 @@ class NetworkManager(QNetworkAccessManager):
|
|||||||
mode=usertypes.PromptMode.user_pwd,
|
mode=usertypes.PromptMode.user_pwd,
|
||||||
owner=reply)
|
owner=reply)
|
||||||
if answer is not None:
|
if answer is not None:
|
||||||
user, password = answer # pylint: disable=unpacking-non-sequence
|
authenticator.setUser(answer.user)
|
||||||
authenticator.setUser(user)
|
authenticator.setPassword(answer.password)
|
||||||
authenticator.setPassword(password)
|
|
||||||
|
|
||||||
@pyqtSlot('QNetworkProxy', 'QAuthenticator')
|
@pyqtSlot('QNetworkProxy', 'QAuthenticator')
|
||||||
def on_proxy_authentication_required(self, proxy, authenticator):
|
def on_proxy_authentication_required(self, proxy, authenticator):
|
||||||
@ -264,10 +263,8 @@ class NetworkManager(QNetworkAccessManager):
|
|||||||
answer = self._ask("Proxy username ({}):".format(
|
answer = self._ask("Proxy username ({}):".format(
|
||||||
authenticator.realm()), mode=usertypes.PromptMode.user_pwd)
|
authenticator.realm()), mode=usertypes.PromptMode.user_pwd)
|
||||||
if answer is not None:
|
if answer is not None:
|
||||||
# pylint: disable=unpacking-non-sequence
|
authenticator.setUser(answer.user)
|
||||||
user, password = answer
|
authenticator.setPassword(answer.password)
|
||||||
authenticator.setUser(user)
|
|
||||||
authenticator.setPassword(password)
|
|
||||||
_proxy_auth_cache[proxy_id] = answer
|
_proxy_auth_cache[proxy_id] = answer
|
||||||
|
|
||||||
@config.change_filter('general', 'private-browsing')
|
@config.change_filter('general', 'private-browsing')
|
||||||
|
@ -33,6 +33,7 @@ from qutebrowser.utils import usertypes, log, qtutils, objreg, utils
|
|||||||
PromptContext = collections.namedtuple('PromptContext',
|
PromptContext = collections.namedtuple('PromptContext',
|
||||||
['question', 'text', 'input_text',
|
['question', 'text', 'input_text',
|
||||||
'echo_mode', 'input_visible'])
|
'echo_mode', 'input_visible'])
|
||||||
|
AuthTuple = collections.namedtuple('AuthTuple', ['user', 'password'])
|
||||||
|
|
||||||
|
|
||||||
class Prompter(QObject):
|
class Prompter(QObject):
|
||||||
@ -237,7 +238,7 @@ class Prompter(QObject):
|
|||||||
elif self._question.mode == usertypes.PromptMode.user_pwd:
|
elif self._question.mode == usertypes.PromptMode.user_pwd:
|
||||||
# User just entered a password
|
# User just entered a password
|
||||||
password = prompt.lineedit.text()
|
password = prompt.lineedit.text()
|
||||||
self._question.answer = (self._question.user, password)
|
self._question.answer = AuthTuple(self._question.user, password)
|
||||||
modeman.maybe_leave(self._win_id, usertypes.KeyMode.prompt,
|
modeman.maybe_leave(self._win_id, usertypes.KeyMode.prompt,
|
||||||
'prompt accept')
|
'prompt accept')
|
||||||
self._question.done()
|
self._question.done()
|
||||||
|
Loading…
Reference in New Issue
Block a user