只能更新自己的节点
This commit is contained in:
1 parent
efbe2b36f3
commit
3e9ff99eaa
1 file changed
+22
-13
+22
-13
@@ -306,6 +306,7 @@ def delete_note():
|
|||||||
# return jsonify({"error": "Note not found"}), 404
|
# return jsonify({"error": "Note not found"}), 404
|
||||||
|
|
||||||
|
|
||||||
|
# 检查是否有子节点
|
||||||
select_payload = {
|
select_payload = {
|
||||||
'action': 'select',
|
'action': 'select',
|
||||||
'table': 'Notes',
|
'table': 'Notes',
|
||||||
@@ -380,23 +381,31 @@ def update_note():
|
|||||||
|
|
||||||
return jsonify({"error": "Invalid param"}), 400
|
return jsonify({"error": "Invalid param"}), 400
|
||||||
|
|
||||||
|
# 获取用户名
|
||||||
|
info = None
|
||||||
|
auth: str = request.headers.get('Authorization', '')
|
||||||
|
if auth.startswith('Bearer '):
|
||||||
|
token: str = auth[7:]
|
||||||
|
info = decode_token(token)
|
||||||
|
|
||||||
if pid != 0:
|
if info is None:
|
||||||
|
return jsonify({"error": "Warning: no Authorization"}), 401
|
||||||
|
|
||||||
select_payload = {
|
|
||||||
'action': 'select',
|
# 检查所有权
|
||||||
'table': 'Notes',
|
select_payload = {
|
||||||
'where': {
|
'action': 'select',
|
||||||
'id': pid
|
'table': 'Notes',
|
||||||
}
|
'where': {
|
||||||
|
'id': id
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
notes = call_db_service(DB_SERVER_URL, select_payload)
|
data = call_db_service(DB_SERVER_URL, select_payload)
|
||||||
|
notes = data['data']
|
||||||
# 不存在的父节点
|
if not info['user'] == 'admin':
|
||||||
if len( notes['data']) == 0:
|
if not len(notes) == 1 or not notes[0]['owner'] == info['user']:
|
||||||
return jsonify({'error': 'the new node need a parent'}), 400
|
return jsonify({"error": 'It\'s not your note'}), 403
|
||||||
|
|
||||||
|
|
||||||
# 内容审查
|
# 内容审查
|
||||||
review = review_content(title + '\n' + content, 10)
|
review = review_content(title + '\n' + content, 10)
|
||||||
|
|||||||
Reference in new issue
Block a user