增加邮箱和手机号登录

pull/1/head
xiaoyu 4 years ago
parent 94754fe2dc
commit 97cb1f08bc
  1. 10
      fir_ser/api/utils/utils.py
  2. 12
      fir_ser/api/views/login.py
  3. 15
      fir_ser/fir_ser/settings.py

@ -142,7 +142,7 @@ def is_valid_email(email):
return False
def get_sender_token(sender, user_id, target):
def get_sender_token(sender, user_id, target,action):
sms_token_obj = DownloadToken()
code = generateNumericTokenOfLength(6)
token = sms_token_obj.make_token(code, time_limit=300, key=user_id)
@ -151,9 +151,9 @@ def get_sender_token(sender, user_id, target):
return token, code
def get_sender_sms_token(key, phone):
def get_sender_sms_token(key, phone,action):
sender = SendMessage('sms')
return get_sender_token(sender, key, phone)
return get_sender_token(sender, key, phone,action)
def is_valid_sender_code(key, token, code):
@ -161,9 +161,9 @@ def is_valid_sender_code(key, token, code):
return sms_token_obj.verify_token(token, code), tmpCache.get_tmp_cache(key, token)
def get_sender_email_token(key, email):
def get_sender_email_token(key, email,action):
sender = SendMessage('email')
return get_sender_token(sender, key, email)
return get_sender_token(sender, key, email,action)
def check_username_exists(username):

@ -62,7 +62,7 @@ def CheckRegisterUerinfo(target, act, key):
res.code = 1005
res.msg = "手机号已经存在"
else:
token, code = get_sender_sms_token(act, target)
token, code = get_sender_sms_token(act, target,'register')
res.data["auth_token"] = token
else:
res.code = 1009
@ -79,7 +79,7 @@ def CheckRegisterUerinfo(target, act, key):
res.code = 1005
res.msg = "邮箱已经存在"
else:
token, code = get_sender_email_token(act, target)
token, code = get_sender_email_token(act, target,'register')
res.data["auth_token"] = token
else:
res.code = 1009
@ -94,7 +94,7 @@ def CheckRegisterUerinfo(target, act, key):
res.code = 1005
res.msg = "用户名已经存在"
else:
token, code = get_sender_email_token(act, target)
token, code = get_sender_email_token(act, target,'register')
res.data["auth_token"] = token
else:
res.code = 1009
@ -124,7 +124,7 @@ def CheckChangeUerinfo(target, act, key, user):
res.code = 1005
res.msg = "手机号已经存在"
else:
token, code = get_sender_sms_token(act, target)
token, code = get_sender_sms_token(act, target,'change')
res.data["auth_token"] = token
else:
res.code = 1009
@ -141,7 +141,7 @@ def CheckChangeUerinfo(target, act, key, user):
res.code = 1005
res.msg = "邮箱已经存在"
else:
token, code = get_sender_email_token(act, target)
token, code = get_sender_email_token(act, target,'change')
res.data["auth_token"] = token
else:
res.code = 1009
@ -156,7 +156,7 @@ def CheckChangeUerinfo(target, act, key, user):
res.code = 1005
res.msg = "用户名已经存在"
else:
token, code = get_sender_email_token(act, target)
token, code = get_sender_email_token(act, target,'change')
res.data["auth_token"] = token
else:
res.code = 1009

@ -171,19 +171,20 @@ REST_FRAMEWORK_EXTENSIONS = {
# 注册方式,如果启用sms或者email 需要配置 THIRD_PART_CONFIG.sender 信息
REGISTER = {
"enable": True,
"ways": {
'sms': True, # 短信注册
"register_type": {
'sms': False, # 短信注册
'email': True, # 邮件注册
'code': False, # 邀请码注册,邀请码必填写,需要和短信,邮件一起使用
}
}
# 信息修改也会使用该配置
LOGIN = {
"ways": [
{'sms': False}, # 短信登录
{'email': True}, # 邮件登录
{'code': False}, # 密码登录
]
"login_type": {
'sms': True, # 短信登录
'email': True, # 邮件登录
'up': True, # 密码登录
}
}
THIRD_PART_CONFIG = {

Loading…
Cancel
Save