Fix a bug

Fix a bug that the high version of ios client cannot log in.
This commit is contained in:
Lost-MSth
2022-01-27 19:26:13 +08:00
parent 5bc9b9a3dc
commit ceebba4664
2 changed files with 6 additions and 5 deletions

View File

@@ -163,10 +163,10 @@ def login():
else:
device_id = 'low_version'
token, error_code, extra = server.auth.arc_login(
token, user_id, error_code, extra = server.auth.arc_login(
name, password, device_id, request.remote_addr)
if not error_code:
r = {"success": True, "token_type": "Bearer"}
r = {"success": True, "token_type": "Bearer", 'user_id': user_id}
r['access_token'] = token
return jsonify(r)
else:

View File

@@ -9,12 +9,13 @@ BAN_TIME = [1, 3, 7, 15, 31]
def arc_login(name: str, password: str, device_id: str, ip: str): # 登录判断
# 查询数据库中的user表验证账号密码返回并记录token多返回个error code和extra
# 查询数据库中的user表验证账号密码返回并记录token和user_id多返回个error code和extra
# token采用user_id和时间戳连接后hash生成真的是瞎想的没用bear
# 密码和token的加密方式为 SHA-256
error_code = 108
token = None
user_id = None
with Connect() as c:
hash_pwd = hashlib.sha256(password.encode("utf8")).hexdigest()
c.execute('''select user_id, password, ban_flag from user where name = :name''', {
@@ -61,7 +62,7 @@ def arc_login(name: str, password: str, device_id: str, ip: str): # 登录判
'''select count(*) from login where user_id=? and login_time>?''', (user_id, now-86400000))
if c.fetchone()[0] >= Config.LOGIN_DEVICE_NUMBER_LIMIT:
remaining_ts = arc_auto_ban(c, user_id, now)
return None, 105, {'remaining_ts': remaining_ts}
return None, None, 105, {'remaining_ts': remaining_ts}
c.execute('''delete from login where rowid in (select rowid from login where user_id=:user_id limit :a);''',
{'user_id': user_id, 'a': int(should_delete_num)})
@@ -76,7 +77,7 @@ def arc_login(name: str, password: str, device_id: str, ip: str): # 登录判
# 用户名错误
error_code = 104
return token, error_code, None
return token, user_id, error_code, None
def arc_register(name: str, password: str, device_id: str, email: str, ip: str): # 注册