Skip to content

Commit

Permalink
Fix Creds for connection call
Browse files Browse the repository at this point in the history
  • Loading branch information
ruuushhh committed Feb 8, 2024
1 parent 25a263b commit 3af2ff6
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions apps/workspaces/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,12 @@ 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
business_central_credentials = BusinessCentralCredentials.objects.update_or_create(
refresh_token=refresh_token, workspace_id=workspace_id, is_expired=False
business_central_credentials = BusinessCentralCredentials.objects.create(
refresh_token=refresh_token, workspace_id=workspace_id
)
else:
# If BusinessCentralCredentials exists, update refresh_token and reset expiration status
Expand Down

0 comments on commit 3af2ff6

Please sign in to comment.