Skip to content

Commit

Permalink
Allow piping the password to login_cli
Browse files Browse the repository at this point in the history
This is useful for testing where entering a password manually is not
possible.
  • Loading branch information
ihabunek committed Aug 28, 2021
1 parent 6115cea commit a3eb5dc
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
1 change: 1 addition & 0 deletions changelog.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 8 additions & 1 deletion toot/auth.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# -*- coding: utf-8 -*-

import sys
import webbrowser

from builtins import input
Expand Down Expand Up @@ -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...")
Expand Down

0 comments on commit a3eb5dc

Please sign in to comment.