Skip to content

Commit ae39ed2

Browse files
authored
Merge pull request #9 from Authing/feature/getVerificationCode
getVerificationCode don't raise exception
2 parents a7dc944 + 68b8d63 commit ae39ed2

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

authing/authing.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -302,8 +302,13 @@ def loginByPhoneCode(self, phone: str, phoneCode: int):
302302
else:
303303
return loginResult
304304

305-
def getVerificationCode(self, phone):
306-
send_sms_spi = "{}/send_smscode/{}/{}".format(
305+
def getVerificationCode(self, phone: str) -> (bool, str):
306+
"""
307+
308+
:param phone: 手机号
309+
:return: 返回一个二元组,第一个表示是否成功,第二个为文字提示
310+
"""
311+
send_sms_spi = "htt{}/send_smscode/{}/{}".format(
307312
self.services['users'].replace("/graphql", ''),
308313
phone,
309314
self.clientId
@@ -312,9 +317,8 @@ def getVerificationCode(self, phone):
312317
resp = urllib.request.urlopen(req)
313318
data = json.loads(resp.read())
314319
code, msg = data['code'], data['message']
315-
if code != 200:
316-
raise Exception(msg)
317-
return data
320+
success = code == 200
321+
return success, msg
318322

319323
def register(self, email=None, password=None):
320324

0 commit comments

Comments
 (0)