Skip to content
This repository has been archived by the owner on Oct 29, 2023. It is now read-only.

Fix handling of SMS OTP whose first digit is 0 #87

Merged
merged 1 commit into from
Aug 9, 2020

Conversation

dequis
Copy link
Contributor

@dequis dequis commented Aug 8, 2020

The cast to int was removing that digit, but it's meaningful.

Without this change, it just keeps requesting the same OTP without sending a new one, and never accepting the user input.


That was originally added in #70 (the original PR that added SMS MFA support) as part of a code review that requested changing input() to use click. There was no requirement to use a type, and the original version worked just fine with input() returning a string.

Copy link
Collaborator

@markusressel markusressel left a comment

Choose a reason for hiding this comment

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

Thx and good catch! 🤓

n26/api.py Outdated
@@ -452,7 +452,7 @@ def _complete_authentication_flow(self, mfa_token: str) -> dict:
mfa_response_data['grant_type'] = "mfa_otp"

hint = click.style("Enter the 6 digit SMS OTP code", fg="yellow")
mfa_response_data['otp'] = click.prompt(hint, type=int)
mfa_response_data['otp'] = click.prompt(hint)
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'd prefer an explicit type=str with a comment above that explains it. This way we will know why this is important lateron.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There!

The cast to int was removing that digit, but it's meaningful.

Without this change, it just keeps requesting the same OTP without
sending a new one, and never accepting the user input.
@dequis dequis force-pushed the sms-otp-starting-with-zero branch from f853dce to 1b1024b Compare August 9, 2020 15:54
@markusressel markusressel merged commit 8fa60a1 into femueller:master Aug 9, 2020
@markusressel
Copy link
Collaborator

Thank you! ❤️

@dequis dequis deleted the sms-otp-starting-with-zero branch August 10, 2020 08:29
# for free to subscribe to this conversation on GitHub. Already have an account? #.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants