Skip to content

Commit

Permalink
Add try block to catch anonymous clients that were cleared from the D…
Browse files Browse the repository at this point in the history
…B. (#3)
  • Loading branch information
tjacovich authored Dec 20, 2024
1 parent c7e71c5 commit ac46ecf
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions apigateway/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from werkzeug.security import gen_salt

from apigateway import email_templates as templates
from apigateway import extensions, schemas
from apigateway import extensions, schemas, exceptions
from apigateway.models import (
EmailChangeRequest,
OAuth2Client,
Expand Down Expand Up @@ -65,8 +65,11 @@ def get(self):
client_id = current_token.client.client_id

if client_id:
client, token = extensions.auth_service.load_client(client_id)

try:
client, token = extensions.auth_service.load_client(client_id)
except exceptions.NoClientError:
client, token = extensions.auth_service.bootstrap_anonymous_user()
session["oauth_client"] = client.client_id
# Check if the client_id is valid and that there is no client/user mismatch
if not client_id or (
client.user_id != current_user.get_id()
Expand Down

0 comments on commit ac46ecf

Please sign in to comment.