Catch ValueErrors in 2fa login step
This commit is contained in:
@@ -341,8 +341,16 @@ class AuthAPI(abc.ABC):
|
|||||||
errcode="password_invalid",
|
errcode="password_invalid",
|
||||||
error="Incorrect password.",
|
error="Incorrect password.",
|
||||||
)
|
)
|
||||||
except Exception:
|
except Exception as e:
|
||||||
self.log.exception("Error sending password")
|
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(
|
return self.get_login_response(
|
||||||
mxid=user.mxid,
|
mxid=user.mxid,
|
||||||
state="password",
|
state="password",
|
||||||
|
|||||||
Reference in New Issue
Block a user