diff --git a/api/chalicelib/core/scope.py b/api/chalicelib/core/scope.py index 28424b334..9a7418129 100644 --- a/api/chalicelib/core/scope.py +++ b/api/chalicelib/core/scope.py @@ -1,6 +1,5 @@ from cachetools import cached, TTLCache -from chalicelib.utils import helper from chalicelib.utils import pg_client cache = TTLCache(maxsize=1, ttl=60) @@ -21,6 +20,6 @@ def update_scope(tenant_id, scope: int): SET scope_state = %(scope_state)s;""", {"scope_state": scope}) cur.execute(query) - if tenant_id in cache: - cache.pop(tenant_id) + if tenant_id in cache: + cache.pop(tenant_id) return scope diff --git a/ee/api/chalicelib/core/scope.py b/ee/api/chalicelib/core/scope.py index f8cb350d0..91e69410a 100644 --- a/ee/api/chalicelib/core/scope.py +++ b/ee/api/chalicelib/core/scope.py @@ -1,6 +1,5 @@ from cachetools import cached, TTLCache -from chalicelib.utils import helper from chalicelib.utils import pg_client cache = TTLCache(maxsize=1000, ttl=60) @@ -24,6 +23,6 @@ def update_scope(tenant_id, scope: int): WHERE tenant_id=%(tenant_id)s;""", {"scope_state": scope, "tenant_id": tenant_id}) cur.execute(query) - if tenant_id in cache: - cache.pop(tenant_id) + if tenant_id in cache: + cache.pop(tenant_id) return scope diff --git a/ee/api/routers/core_dynamic.py b/ee/api/routers/core_dynamic.py index b429e06aa..1272f4950 100644 --- a/ee/api/routers/core_dynamic.py +++ b/ee/api/routers/core_dynamic.py @@ -147,7 +147,7 @@ def edit_account(data: schemas.EditAccountSchema = Body(...), @app.post('/account/scope', tags=["account"]) def change_scope(data: schemas.ScopeSchema = Body(), context: schemas.CurrentContext = Depends(OR_context)): - data = scope.update_scope(tenant_id=-1, scope=data.scope) + data = scope.update_scope(tenant_id=context.tenant_id, scope=data.scope) return {'data': data}