1
0
mirror of https://github.com/LibreTranslate/LibreTranslate.git synced 2024-12-18 08:27:03 +02:00

Better error message when API key link is available

This commit is contained in:
Piero Toffanin 2022-06-21 16:39:08 -04:00
parent 47fc85fdec
commit 78d2bc7be4

View File

@ -195,9 +195,12 @@ def create_app(args):
and api_keys_db.lookup(ak) is None and api_keys_db.lookup(ak) is None
and request.headers.get("Origin") != args.require_api_key_origin and request.headers.get("Origin") != args.require_api_key_origin
): ):
description = "Please contact the server operator to get an API key"
if args.get_api_key_link:
description = "Visit %s to get an API key" % args.get_api_key_link
abort( abort(
403, 403,
description="Please contact the server operator to obtain an API key", description=description,
) )
return f(*a, **kw) return f(*a, **kw)