Skip to content

Commit

Permalink
fix: require phone_number when verify sms code
Browse files Browse the repository at this point in the history
  • Loading branch information
Wu Yun committed Mar 29, 2024
1 parent 82f48c5 commit 2951c7e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
9 changes: 5 additions & 4 deletions leancloud/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -335,8 +335,8 @@ def request_password_reset_by_sms_code(cls, phone_number, validate_token=None):
client.post("/requestPasswordResetBySmsCode", params)

@classmethod
def reset_password_by_sms_code(cls, sms_code, new_password):
params = {"password": new_password}
def reset_password_by_sms_code(cls, sms_code, new_password, phone_number):
params = {"password": new_password, "mobilePhoneNumber": phone_number}
client.put("/resetPasswordBySmsCode/" + sms_code, params)

# This should be an instance method.
Expand All @@ -359,8 +359,9 @@ def change_phone_number(cls, sms_code, phone_number):
client.post("/changePhoneNumber", params)

@classmethod
def verify_mobile_phone_number(cls, sms_code):
client.post("/verifyMobilePhone/" + sms_code, {})
def verify_mobile_phone_number(cls, sms_code, phone_number):
params = {"mobilePhoneNumber": phone_number}
client.post("/verifyMobilePhone/" + sms_code, params)

@classmethod
def request_login_sms_code(cls, phone_number, validate_token=None):
Expand Down
4 changes: 3 additions & 1 deletion tests/test_user.py
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,9 @@ def test_request_password_reset_by_sms_code(): # type: () -> None
def test_reset_password_by_sms_code(): # type: () -> None
try:
User.reset_password_by_sms_code(
str(random.randrange(100000, 999999)), "password"
str(random.randrange(100000, 999999)),
"password",
"1861111" + str(random.randrange(1000, 9999))
)
except LeanCloudError as e:
if e.code != 603:
Expand Down

0 comments on commit 2951c7e

Please sign in to comment.