support to parse dash in otp secret (#3309)

This commit is contained in:
LawyZheng
2025-08-28 14:17:29 +08:00
committed by GitHub
parent 17501da7cb
commit 49670505e3

View File

@@ -18,7 +18,8 @@ def parse_totp_secret(totp_secret: str) -> str:
if not totp_secret:
return ""
totp_secret_no_whitespace = "".join(totp_secret.split())
totp_secret_no_dashe = "".join(totp_secret.split("-"))
totp_secret_no_whitespace = "".join(totp_secret_no_dashe.split())
try:
# to verify if it's a valid TOTP secret
pyotp.TOTP(totp_secret_no_whitespace).byte_secret()