diff --git a/nest_backend/routes/repository/conditions/repository_conditions.py b/nest_backend/routes/repository/conditions/repository_conditions.py index 24458c4..6cca26e 100644 --- a/nest_backend/routes/repository/conditions/repository_conditions.py +++ b/nest_backend/routes/repository/conditions/repository_conditions.py @@ -78,15 +78,15 @@ def page_repository_conditions(rid): return json_error("Could not find repository", REPOSITORY_NOT_FOUND), 404 user = find_user(get_jwt_identity()) - if user.email != repository.owner_id: - return json_error("You are not authorized.", REPOSITORY_NOT_OWNER), 403 - if request.method == "GET": try: return json_success([u.to_json() for u in repository.conditions]) except Exception as e: return json_error("Unknown error:" + str(e), GENERIC_UFO), 400 + if user.email != repository.owner_id: + return json_error("You are not authorized.", REPOSITORY_NOT_OWNER), 403 + if request.method == "POST": if request.json is None: return json_error("Missing json content.", GENERIC_NO_JSON), 400 diff --git a/nest_backend/routes/repository/repository.py b/nest_backend/routes/repository/repository.py index 22548d7..68c4d3e 100644 --- a/nest_backend/routes/repository/repository.py +++ b/nest_backend/routes/repository/repository.py @@ -159,9 +159,9 @@ def page_repository(rid): return json_error("Could not find repository.", REPOSITORY_NOT_FOUND), 404 if request.method == "GET": return json_success(repository.to_json()), 200 + if user.email != repository.owner_id: + return json_error("You are not the owner of this repository.", REPOSITORY_NOT_OWNER), 403 elif request.method == "PATCH": - if repository.owner_id != user.email: - return json_error("You are not the owner of this repository.", REPOSITORY_NOT_OWNER), 403 if 'name' in request.json: repository.name = request.json['name'] if 'close' in request.json and not repository.end and repository.is_active: @@ -178,8 +178,6 @@ def page_repository(rid): ext.session.commit() return json_success(repository.to_json()), 204 elif request.method == "DELETE": - if repository.owner_id != user.email and not user.isAdmin: - return json_error("You are not the owner of this repository.", REPOSITORY_NOT_OWNER), 403 try: repository.is_deleted = True ext.session.commit() diff --git a/nest_crawler/__main__.py b/nest_crawler/__main__.py index e24b264..20391f9 100644 --- a/nest_crawler/__main__.py +++ b/nest_crawler/__main__.py @@ -1,6 +1,6 @@ from nest_backend.database import * from nest_backend.app import app, extension_sqlalchemy -from repo_search import search_repo_conditions +from nest_crawler.repo_search import search_repo_conditions from alert_trigger import is_repo_alert_triggered ext.init_app(app=app) diff --git a/nest_crawler/repo_search.py b/nest_crawler/repo_search.py index 55601ec..9d1817a 100644 --- a/nest_crawler/repo_search.py +++ b/nest_crawler/repo_search.py @@ -1,5 +1,5 @@ from nest_backend.database import * -from .authentication import authenticate +from nest_crawler.authentication import authenticate from datetime import datetime, timedelta import tweepy as tw