Have catalog endpoint return empty if the namespace is disabled
This commit is contained in:
parent
98ffdf0e84
commit
2e0edf8f6e
1 changed files with 8 additions and 2 deletions
|
@ -1,6 +1,6 @@
|
||||||
import features
|
import features
|
||||||
|
|
||||||
from flask import jsonify
|
from flask import jsonify, abort
|
||||||
|
|
||||||
from auth.auth_context import get_authenticated_user
|
from auth.auth_context import get_authenticated_user
|
||||||
from auth.registry_jwt_auth import process_registry_jwt_auth
|
from auth.registry_jwt_auth import process_registry_jwt_auth
|
||||||
|
@ -14,8 +14,14 @@ from endpoints.v2.models_pre_oci import data_model as model
|
||||||
@anon_protect
|
@anon_protect
|
||||||
@paginate()
|
@paginate()
|
||||||
def catalog_search(limit, offset, pagination_callback):
|
def catalog_search(limit, offset, pagination_callback):
|
||||||
username = get_authenticated_user().username if get_authenticated_user() else None
|
|
||||||
include_public = bool(features.PUBLIC_CATALOG)
|
include_public = bool(features.PUBLIC_CATALOG)
|
||||||
|
if not include_public and not get_authenticated_user():
|
||||||
|
return jsonify({'repositories': []})
|
||||||
|
|
||||||
|
username = get_authenticated_user().username if get_authenticated_user() else None
|
||||||
|
if username and not get_authenticated_user().enabled:
|
||||||
|
return jsonify({'repositories': []})
|
||||||
|
|
||||||
visible_repositories = model.get_visible_repositories(username, limit + 1, offset,
|
visible_repositories = model.get_visible_repositories(username, limit + 1, offset,
|
||||||
include_public=include_public)
|
include_public=include_public)
|
||||||
response = jsonify({
|
response = jsonify({
|
||||||
|
|
Reference in a new issue