Skip to content

Commit

Permalink
codacy fix
Browse files Browse the repository at this point in the history
  • Loading branch information
wbaccinelli committed Feb 27, 2024
1 parent 743cd59 commit 34932ca
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 544 deletions.
7 changes: 3 additions & 4 deletions vantage6-algorithm-store/vantage6/algorithm/store/__init__.py
Expand Up @@ -49,7 +49,6 @@

# TODO move server imports to common / refactor
from vantage6.algorithm.store.permission import PermissionManager
from vantage6.algorithm.store.globals import RESOURCES, SERVER_MODULE_NAME

module_name = logger_name(__name__)
log = logging.getLogger(module_name)
Expand Down Expand Up @@ -286,20 +285,20 @@ def start(self) -> None:
v6_server.save()

if (username := root_user.get("username")) and (
id := root_user.get("id_server")
id_server := root_user.get("id_server")
):

v6_server = db.Vantage6Server.get_by_url(whitelisted_uri)
# if the user does not exist already, add it
if not db.User.get_by_server(
id_server=id, v6_server_id=v6_server.id
id_server=id_server, v6_server_id=v6_server.id
):
log.warning("Creating root user")

root = db.Role.get_by_name("Root")

user = db.User(
id_server=id,
id_server=id_server,
v6_server_id=v6_server.id,
username=username,
roles=[root],
Expand Down
Expand Up @@ -2,7 +2,7 @@
import importlib

from collections import namedtuple
from flask_principal import Permission, PermissionDenied
from flask_principal import Permission

from vantage6.algorithm.store.globals import RESOURCES
from vantage6.algorithm.store.default_roles import DefaultRole
Expand Down
Expand Up @@ -202,7 +202,8 @@ def decorator(*args, **kwargs):
g.user = user

if not user.can(resource, operation):
msg = f"You are not allowed to perform this operation"
msg = (f"You are not allowed to perform this operation: {operation}"
f"on this resource: {resource}")

log.warning(msg)
return {"msg": msg}, HTTPStatus.UNAUTHORIZED
Expand Down

0 comments on commit 34932ca

Please sign in to comment.