Skip to content

Commit

Permalink
Fix Creds for connection call (#93)
Browse files Browse the repository at this point in the history
* Fix Creds for connection call

* Fix Creds for connection call

* Fix Creds for connection call
  • Loading branch information
ruuushhh authored Feb 12, 2024
1 parent 59ca2d2 commit a6642d0
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 3 additions & 1 deletion apps/business_central/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,9 @@ def get_company(self, workspace_id):
Get Company
"""
try:
business_central_credentials: BusinessCentralCredentials = BusinessCentralCredentials.get_active_business_central_credentials(workspace_id)
business_central_credentials: BusinessCentralCredentials = BusinessCentralCredentials.objects.get(
workspace_id=workspace_id, is_expired=False, refresh_token__isnull=False
)

business_central_connector = BusinessCentralConnector(business_central_credentials, workspace_id=workspace_id)

Expand Down
2 changes: 1 addition & 1 deletion apps/workspaces/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def connect_business_central(authorization_code, redirect_uri, workspace_id):
refresh_token = generate_business_central_refresh_token(authorization_code, redirect_uri)

# Retrieve or create BusinessCentralCredentials based on workspace_id
business_central_credentials = BusinessCentralCredentials.get_active_business_central_credentials(workspace_id)
business_central_credentials = BusinessCentralCredentials.objects.filter(workspace_id=workspace_id).first()

if not business_central_credentials:
# If BusinessCentralCredentials does not exist, create a new one
Expand Down

0 comments on commit a6642d0

Please sign in to comment.