Catch ValueErrors in 2fa login step

This commit is contained in:
Tulir Asokan
2023-01-02 17:46:54 +02:00
parent 2303622475
commit e3d2a1fcef
+9 -1
View File
@@ -341,8 +341,16 @@ class AuthAPI(abc.ABC):
errcode="password_invalid",
error="Incorrect password.",
)
except Exception:
except Exception as e:
self.log.exception("Error sending password")
if isinstance(e, ValueError) and "You must provide a phone and a code" in str(e):
return self.get_login_response(
mxid=user.mxid,
state="request",
status=400,
errcode="phone_code_not_entered",
error="Please request a new phone code and enter it first.",
)
return self.get_login_response(
mxid=user.mxid,
state="password",