Merge pull request #7781 from dezeroku/cleaned-up
userscripts: fix qute-bitwarden failing with expired session
This commit is contained in:
commit
4a675115e1
|
|
@ -133,7 +133,7 @@ def get_session_key(auto_lock, password_prompt_invocation):
|
|||
def pass_(domain, encoding, auto_lock, password_prompt_invocation):
|
||||
session_key = get_session_key(auto_lock, password_prompt_invocation)
|
||||
process = subprocess.run(
|
||||
['bw', 'list', 'items', '--session', session_key, '--url', domain],
|
||||
['bw', 'list', 'items', '--nointeraction', '--session', session_key, '--url', domain],
|
||||
capture_output=True,
|
||||
)
|
||||
|
||||
|
|
@ -142,6 +142,10 @@ def pass_(domain, encoding, auto_lock, password_prompt_invocation):
|
|||
msg = 'Bitwarden CLI returned for {:s} - {:s}'.format(domain, err)
|
||||
stderr(msg)
|
||||
|
||||
if "Vault is locked" in err:
|
||||
stderr("Bitwarden Vault got locked, trying again with clean session")
|
||||
return pass_(domain, encoding, 0, password_prompt_invocation)
|
||||
|
||||
if process.returncode:
|
||||
return '[]'
|
||||
|
||||
|
|
@ -153,7 +157,7 @@ def pass_(domain, encoding, auto_lock, password_prompt_invocation):
|
|||
def get_totp_code(selection_id, domain_name, encoding, auto_lock, password_prompt_invocation):
|
||||
session_key = get_session_key(auto_lock, password_prompt_invocation)
|
||||
process = subprocess.run(
|
||||
['bw', 'get', 'totp', '--session', session_key, selection_id],
|
||||
['bw', 'get', 'totp', '--nointeraction', '--session', session_key, selection_id],
|
||||
capture_output=True,
|
||||
)
|
||||
|
||||
|
|
@ -163,6 +167,10 @@ def get_totp_code(selection_id, domain_name, encoding, auto_lock, password_promp
|
|||
msg = 'Bitwarden CLI returned for {:s} - {:s}'.format(domain_name, err)
|
||||
stderr(msg)
|
||||
|
||||
if "Vault is locked" in err:
|
||||
stderr("Bitwarden Vault got locked, trying again with clean session")
|
||||
return get_totp_code(selection_id, domain_name, encoding, 0, password_prompt_invocation)
|
||||
|
||||
if process.returncode:
|
||||
return '[]'
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue