Make oauthexceptions be http status 400 on signup as well master github/master
authorMagnus Hagander <magnus@hagander.net>
Thu, 12 Jun 2025 08:21:50 +0000 (10:21 +0200)
committerMagnus Hagander <magnus@hagander.net>
Thu, 12 Jun 2025 08:21:50 +0000 (10:21 +0200)
This was already done for the majority on signin, but for new accounts
we should do the same.

pgweb/account/views.py

index 4f40c11e16e213679f0fce4f5f67c27da518ce65..809d4bea9f9ef974d42cb8ecd089b9688f648bef 100644 (file)
@@ -45,6 +45,7 @@ from .forms import SignupForm, SignupOauthForm
 from .forms import UserForm, UserProfileForm, ContributorForm
 from .forms import AddEmailForm, PgwebPasswordResetForm
 from .oauthclient import get_encrypted_oauth_cookie, delete_encrypted_oauth_cookie_on
+from .oauthclient import OAuthException
 
 import logging
 
@@ -542,7 +543,10 @@ def signup_complete(request):
 @transaction.atomic
 @queryparams('do_abort')
 def signup_oauth(request):
-    cookiedata = get_encrypted_oauth_cookie(request)
+    try:
+        cookiedata = get_encrypted_oauth_cookie(request)
+    except OAuthException as e:
+        return HttpResponse(e, status=400)
 
     if 'oauth_email' not in cookiedata \
        or 'oauth_firstname' not in cookiedata \