修改format2username方法,返回元组作为结果判断。

悠resetpwd.views 将所有format2username兼容处理,防止当用户名为空时,能正确抛出异常给前端页面。
修复resetpwd.views callback_check中一个BUG(如果用户不存在或未激活,会存在通过format2username拿不到用户名的情况,在这里就直接抛出user_info整个json)
This commit is contained in:
向乐🌌
2021-08-05 09:35:56 +08:00
parent 4f8fcb68b4
commit 75b3916191
4 changed files with 61 additions and 18 deletions

View File

@@ -20,13 +20,13 @@ def format2username(account):
domain_compile = re.compile(r'(.*)\\(.*)')
if re.fullmatch(mail_compile, account):
return re.fullmatch(mail_compile, account).group(1)
return True, re.fullmatch(mail_compile, account).group(1)
elif re.fullmatch(domain_compile, account):
return re.fullmatch(domain_compile, account).group(2)
return True, re.fullmatch(domain_compile, account).group(2)
else:
return account.lower()
return True, account.lower()
else:
raise NameError("输入的账号不能为空..")
return False, NameError("{}格式化失败注意account用户账号是邮箱或DOMAIN\\username或username格式".format(account))
def get_user_is_active(user_info):