Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve handling of multiple credentials #144

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

RealCLanger
Copy link
Contributor

@RealCLanger RealCLanger commented Nov 21, 2024

Hi,

I'm taking another attempt to fix #38 (Session is not invalidated when a new login with different number occurs) which hits me as well. There has already be an effort in #56 but it seems that this went stale.

My idea is to store the cookies in a file that is named after the phone number which is the id of a trade republic account. So there can be no conflicts in cookies if the tool is used with multiple accounts.

I also remove the prompt that asks whether one would like to save the credentials and replace it with a command line option --store_credentials which defaults to true. I find the prompt rather annoying, especially for scripted calls of pytr.

Comments/Suggestions?

Cheers
Christoph

Copy link
Contributor

@pinzutu pinzutu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That aside, being able to store multiple credentials seems like a useful feature to have👍

@@ -19,14 +19,13 @@ def get_settings(tr):
return formatted_json


def login(phone_no=None, pin=None, web=True):
def login(phone_no=None, pin=None, web=True, store_credentials=True):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
def login(phone_no=None, pin=None, web=True, store_credentials=True):
def login(phone_no=None, pin=None, web=True, store_credentials=False):

"--store_credentials",
help="Store credentials (Phone number and pin) for next usage",
action="store_true",
default=True
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wouldn't save the credentials in a clear file per default when this behavior is not explicitly highlighted to the user.

Suggested change
default=True

log.info("Credentials not saved")

tr = TradeRepublicApi(phone_no=phone_no, pin=pin, save_cookies=save_cookies)
tr = TradeRepublicApi(phone_no=phone_no, pin=pin, save_cookies=True)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same critique here, the default behavior should not be to leave clear file cookies on your system indefinitely.

Suggested change
tr = TradeRepublicApi(phone_no=phone_no, pin=pin, save_cookies=True)
else:
save_cookies = False
log.info("Credentials not saved")
tr = TradeRepublicApi(phone_no=phone_no, pin=pin, save_cookies=save_cookies)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Session is not invalidated when a new login with different number occurs
2 participants