Allow piping the password to login_cli

This is useful for testing where entering a password manually is not
possible.
This commit is contained in:
Ivan Habunek 2021-08-28 20:36:10 +02:00
parent 6115cea43e
commit a3eb5dca24
No known key found for this signature in database
GPG Key ID: CDBD63C43A30BB95
2 changed files with 9 additions and 1 deletions

View File

@ -4,6 +4,7 @@
- "Add `--scheduled-at` option to `toot post`, allows scheduling toots"
- "Add `--description` option to `toot post`, for adding descriptions to media attachments (thanks @ansuz)"
- "Disable paging timeline when output is piped (thanks @stacyharper)"
- "Allow piping the password to login_cli for testing purposes (thanks @NinjaTrappeur)"
0.27.0:
date: 2020-06-15

View File

@ -1,5 +1,6 @@
# -*- coding: utf-8 -*-
import sys
import webbrowser
from builtins import input
@ -66,7 +67,13 @@ def login_interactive(app, email=None):
while not email:
email = input('Email: ')
password = getpass('Password: ')
# Accept password piped from stdin, useful for testing purposes but not
# documented so people won't get ideas. Otherwise prompt for password.
if sys.stdin.isatty():
password = getpass('Password: ')
else:
password = sys.stdin.read().strip()
print_out("Password: <green>read from stdin</green>")
try:
print_out("Authenticating...")