fix: 修复部门删除异常,用户登录失败日志异常
This commit is contained in:
parent
78ab92cdb6
commit
0a2372a99c
@ -147,18 +147,18 @@ class Log:
|
||||
# if request_from_swagger or request_from_redoc:
|
||||
# pass
|
||||
# else:
|
||||
if status == 1:
|
||||
session_id = request.app.state.session_id
|
||||
current_user = await User.get_or_none(username=payload.get("username"))
|
||||
await LoginLog.create(
|
||||
user_id=current_user.id,
|
||||
login_ip=host,
|
||||
login_location=location,
|
||||
browser=browser,
|
||||
os=system_os,
|
||||
status=status,
|
||||
session_id=session_id
|
||||
)
|
||||
session_id = request.app.state.session_id
|
||||
status = 1 if request.app.state.login_status else 0
|
||||
current_user = await User.get_or_none(username=payload.get("username"))
|
||||
await LoginLog.create(
|
||||
user_id=current_user.id,
|
||||
login_ip=host,
|
||||
login_location=location,
|
||||
browser=browser,
|
||||
os=system_os,
|
||||
status=status,
|
||||
session_id=session_id
|
||||
)
|
||||
else:
|
||||
if "image" in request.headers.get("Accept", ""):
|
||||
pass
|
||||
|
@ -74,7 +74,7 @@ async def delete_department_recursive(department_id: str):
|
||||
:return:
|
||||
"""
|
||||
await Department.filter(id=department_id).delete()
|
||||
sub_departments = await Department.filter(parentId=department_id).all()
|
||||
sub_departments = await Department.filter(parent_id=department_id).all()
|
||||
for sub_department in sub_departments:
|
||||
await delete_department_recursive(sub_department.id)
|
||||
return True
|
||||
|
@ -33,7 +33,7 @@ async def get_login_log(request: Request,
|
||||
):
|
||||
online_user_list = await LoginController.get_online_user(request)
|
||||
online_user_list = list(
|
||||
filter(lambda x: x["user_id"] == current_user.get("id"), jsonable_encoder(online_user_list, )))
|
||||
filter(lambda x: x["user_id"] == current_user.get("id"), jsonable_encoder(online_user_list)))
|
||||
user_id = current_user.get("id")
|
||||
result = await LoginLog.filter(user_id=user_id, del_flag=1).offset((page - 1) * pageSize).limit(pageSize).values(
|
||||
id="id",
|
||||
|
@ -38,6 +38,8 @@ async def login(
|
||||
request: Request,
|
||||
params: CustomOAuth2PasswordRequestForm = Depends()
|
||||
):
|
||||
request.app.state.session_id = None
|
||||
request.app.state.login_status = False
|
||||
user = LoginParams(
|
||||
username=params.username,
|
||||
password=params.password,
|
||||
@ -47,7 +49,7 @@ async def login(
|
||||
)
|
||||
captcha_enabled = (
|
||||
True
|
||||
if await request.app.state.redis.get(f'{RedisKeyConfig.SYSTEM_CONFIG.key}:account.captcha_enabled')
|
||||
if await request.app.state.redis.get(f'{RedisKeyConfig.SYSTEM_CONFIG.key}:account_captcha_enabled')
|
||||
== 'true'
|
||||
else False
|
||||
)
|
||||
@ -75,6 +77,7 @@ async def login(
|
||||
ex=timedelta(minutes=5),
|
||||
)
|
||||
request.app.state.session_id = result["session_id"]
|
||||
request.app.state.login_status = True
|
||||
if request_from_swagger or request_from_redoc:
|
||||
return {'access_token': result["accessToken"], 'token_type': 'Bearer',
|
||||
"expires_in": result["expiresIn"] * 60}
|
||||
@ -83,6 +86,7 @@ async def login(
|
||||
result.pop("session_id")
|
||||
result.pop("userInfo")
|
||||
return Response.success(data=result)
|
||||
request.app.state.login_status = False
|
||||
return Response.failure(msg="登录失败,账号或密码错误!")
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user