请求中的 Content-Type 不是 application/json,则从 request.values 中读取请求参数
Signed-off-by: funewa <yuge@funewa.com>
This commit is contained in:
@@ -32,12 +32,13 @@ def login_log(request, uid, is_access):
|
|||||||
|
|
||||||
|
|
||||||
def admin_log(request, is_access):
|
def admin_log(request, is_access):
|
||||||
|
request_data = request.json if request.headers.get('Content-Type') == 'application/json' else request.values
|
||||||
info = {
|
info = {
|
||||||
'method': request.method,
|
'method': request.method,
|
||||||
'url': request.path,
|
'url': request.path,
|
||||||
'ip': request.remote_addr,
|
'ip': request.remote_addr,
|
||||||
'user_agent': str_escape(request.headers.get('User-Agent')),
|
'user_agent': str_escape(request.headers.get('User-Agent')),
|
||||||
'desc': str_escape(str(dict(request.values if request.method == 'GET' else request.json))),
|
'desc': str_escape(str(dict(request_data))),
|
||||||
'uid': current_user.id,
|
'uid': current_user.id,
|
||||||
'success': int(is_access)
|
'success': int(is_access)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user