mirror of
https://git.mirrors.martin98.com/https://github.com/infiniflow/ragflow.git
synced 2025-08-12 12:09:03 +08:00
Fix API key validation api/conversation (#2100)
### What problem does this PR solve? #2081 ### Type of change - [x] Bug Fix (non-breaking change which fixes an issue)
This commit is contained in:
parent
6d3e3e4e3c
commit
13785edaae
@ -344,12 +344,22 @@ def completion():
|
|||||||
@manager.route('/conversation/<conversation_id>', methods=['GET'])
|
@manager.route('/conversation/<conversation_id>', methods=['GET'])
|
||||||
# @login_required
|
# @login_required
|
||||||
def get(conversation_id):
|
def get(conversation_id):
|
||||||
|
token = request.headers.get('Authorization').split()[1]
|
||||||
|
objs = APIToken.query(token=token)
|
||||||
|
if not objs:
|
||||||
|
return get_json_result(
|
||||||
|
data=False, retmsg='Token is not valid!"', retcode=RetCode.AUTHENTICATION_ERROR)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
e, conv = API4ConversationService.get_by_id(conversation_id)
|
e, conv = API4ConversationService.get_by_id(conversation_id)
|
||||||
if not e:
|
if not e:
|
||||||
return get_data_error_result(retmsg="Conversation not found!")
|
return get_data_error_result(retmsg="Conversation not found!")
|
||||||
|
|
||||||
conv = conv.to_dict()
|
conv = conv.to_dict()
|
||||||
|
if token != APIToken.query(dialog_id=conv['dialog_id'])[0].token:
|
||||||
|
return get_json_result(data=False, retmsg='Token is not valid for this conversation_id!"',
|
||||||
|
retcode=RetCode.AUTHENTICATION_ERROR)
|
||||||
|
|
||||||
for referenct_i in conv['reference']:
|
for referenct_i in conv['reference']:
|
||||||
if referenct_i is None or len(referenct_i) == 0:
|
if referenct_i is None or len(referenct_i) == 0:
|
||||||
continue
|
continue
|
||||||
@ -769,4 +779,4 @@ def retrieval():
|
|||||||
if str(e).find("not_found") > 0:
|
if str(e).find("not_found") > 0:
|
||||||
return get_json_result(data=False, retmsg=f'No chunk found! Check the chunk status please!',
|
return get_json_result(data=False, retmsg=f'No chunk found! Check the chunk status please!',
|
||||||
retcode=RetCode.DATA_ERROR)
|
retcode=RetCode.DATA_ERROR)
|
||||||
return server_error_response(e)
|
return server_error_response(e)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user