Skip to content

Commit

Permalink
Merge pull request #9 from Authing/feature/getVerificationCode
Browse files Browse the repository at this point in the history
getVerificationCode don't raise exception
  • Loading branch information
leinue committed Oct 25, 2019
2 parents a7dc944 + 68b8d63 commit ae39ed2
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions authing/authing.py
Original file line number Diff line number Diff line change
Expand Up @@ -302,8 +302,13 @@ def loginByPhoneCode(self, phone: str, phoneCode: int):
else:
return loginResult

def getVerificationCode(self, phone):
send_sms_spi = "{}/send_smscode/{}/{}".format(
def getVerificationCode(self, phone: str) -> (bool, str):
"""
:param phone: 手机号
:return: 返回一个二元组,第一个表示是否成功,第二个为文字提示
"""
send_sms_spi = "htt{}/send_smscode/{}/{}".format(
self.services['users'].replace("/graphql", ''),
phone,
self.clientId
Expand All @@ -312,9 +317,8 @@ def getVerificationCode(self, phone):
resp = urllib.request.urlopen(req)
data = json.loads(resp.read())
code, msg = data['code'], data['message']
if code != 200:
raise Exception(msg)
return data
success = code == 200
return success, msg

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

Expand Down

0 comments on commit ae39ed2

Please sign in to comment.