Standardize token argument in routes.
- `token` becomes `portfolio_token` in routes. - Find relevant portfolio from token in `before_request` hook, like other routes.
This commit is contained in:
@@ -3,11 +3,6 @@ from functools import wraps
|
||||
from flask import g, current_app as app, request
|
||||
|
||||
from . import user_can_access
|
||||
from atst.domain.portfolios import Portfolios
|
||||
from atst.domain.task_orders import TaskOrders
|
||||
from atst.domain.applications import Applications
|
||||
from atst.domain.environments import Environments
|
||||
from atst.domain.invitations import PortfolioInvitations
|
||||
from atst.domain.exceptions import UnauthorizedError
|
||||
|
||||
|
||||
@@ -18,14 +13,6 @@ def check_access(permission, message, override, *args, **kwargs):
|
||||
"application": g.application,
|
||||
}
|
||||
|
||||
# TODO: We should change the `token` arg in routes to be either
|
||||
# `portfolio_token` or `application_token` and have
|
||||
# atst.utils.context_processors.assign_resources take care of
|
||||
# this.
|
||||
if "token" in kwargs:
|
||||
invite = PortfolioInvitations._get(kwargs["token"])
|
||||
access_args["portfolio"] = invite.role.portfolio
|
||||
|
||||
if override is not None and override(g.current_user, **access_args, **kwargs):
|
||||
return True
|
||||
|
||||
|
||||
Reference in New Issue
Block a user