Skip to content

Commit 7bfd810

Browse files
committed
Bug fixes
Fixes an issue in the accounts template expecting homepage_account and fixes an issue where prereg attendees were added to the session for validating and then not removed, causing a 500 error if you clicked the Stripe payment button more than once. Also removes a stray debugging log statement.
1 parent a270496 commit 7bfd810

File tree

3 files changed

+12
-9
lines changed

3 files changed

+12
-9
lines changed

uber/auth.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@ def _fetch_key(self, kid):
6464
return None
6565
self.key_fetch_time = time.time()
6666
oidc_config = requests.get(c.OIDC_METADATA_URL).json()
67-
log.error(oidc_config)
6867
jwks_uri = oidc_config['jwks_uri']
6968

7069
keys = requests.get(jwks_uri).json()['keys']

uber/site_sections/preregistration.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
import secrets
1212
from collections import defaultdict
1313
from sqlalchemy import func, or_
14-
from sqlalchemy.orm import selectinload, joinedload
14+
from sqlalchemy.orm import selectinload, joinedload, make_transient
1515
from sqlalchemy.orm.exc import NoResultFound
1616

1717
from uber.config import c
@@ -891,12 +891,15 @@ def prereg_payment(self, session, message='', **params):
891891

892892
used_codes = defaultdict(int)
893893
for attendee in cart.attendees:
894+
session.add(attendee)
894895
used_codes[attendee.promo_code_code] += 1
895896
form_list = ['BadgeExtras'] # Re-check purchase limits
896897

897898
forms = load_forms(params, attendee, form_list, checkboxes_present=False)
898899

899900
all_errors = validate_model(session, forms, attendee, create_preview_model=False)
901+
session.expunge(attendee)
902+
make_transient(attendee)
900903
if all_errors:
901904
message = ' '.join([item for sublist in all_errors.values() for item in sublist])
902905

uber/templates/preregistration/preregbase.html

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@
22
{% import "forms/account.html" as account_fields with context %}
33

44
{% block backlink %}
5+
{% set account = account or logged_in_account or session.current_attendee_account() %}
56
{% if c.ATTENDEE_ACCOUNTS_ENABLED or c.HAS_REGISTRATION_ACCESS or c.HAS_GROUP_ADMIN_ACCESS %}
67
<nav class="navbar navbar-expand-lg">
78
<div class="container-fluid">
8-
<div class="badge bg-dark">Logged in as: {{ homepage_account.email }}</div>
9+
<div class="badge bg-dark">Logged in as: {{ account.email }}</div>
910
<div class="d-flex justify-content-end gap-2">
1011
{% if c.HAS_REGISTRATION_ACCESS and attendee and not attendee.is_new %}
1112
<a class="btn btn-secondary btn-sm" href="../registration/form?id={{ attendee.id }}">Admin Form</a>
@@ -20,9 +21,9 @@
2021
{% elif c.CURRENT_ADMIN %}
2122
<a href="../accounts/homepage" class="btn btn-secondary btn-sm">Admin Area</a>
2223
{% endif %}
23-
{% if c.ATTENDEE_ACCOUNTS_ENABLED and (logged_in_account or homepage_account) %}
24+
{% if c.ATTENDEE_ACCOUNTS_ENABLED and account %}
2425
{% if c.PAGE_PATH != '/preregistration/homepage' %}<a class="btn btn-info btn-sm" href="../preregistration/homepage">Homepage</a>{% endif %}
25-
{% if homepage_account and (not homepage_account.is_sso_account or c.LOCAL_ACCOUNTS_DISABLED) %}
26+
{% if account and (not account.is_sso_account or c.LOCAL_ACCOUNTS_DISABLED) %}
2627
<button class="btn btn-warning btn-sm" type="button" data-bs-toggle="modal" data-bs-target="#account_settings">
2728
<i class="fa fa-cog"></i> Account Settings
2829
</button>
@@ -50,13 +51,13 @@ <h4 class="modal-title" id="account_settings_title">
5051
<div class="modal-body">
5152
<form method="post" action="update_account">
5253
{{ csrf_token() }}
53-
<input type="hidden" name="id" value="{{ homepage_account.id }}" />
54+
<input type="hidden" name="id" value="{{ account.id }}" />
5455
<input type="hidden" name="return_to" value="..{{ c.PAGE_PATH }}?{{ c.QUERY_STRING_NO_MSG }}" />
55-
{% if homepage_account.is_sso_account and c.OIDC_ENABLED %}
56+
{% if account.is_sso_account and c.OIDC_ENABLED %}
5657
<div class="row g-3">
5758
<div class="col-sm">
5859
<label for="email" class="form-text">Account Notifications Email</label>
59-
<input type="email" name="account_email" id="account_email" value="{{ homepage_account.email }}" class="form-control" placeholder="Account email address" required>
60+
<input type="email" name="account_email" id="account_email" value="{{ account.email }}" class="form-control" placeholder="Account email address" required>
6061
<p class="form-text">This is the email we'll use to send notifications about your {{ c.EVENT_NAME_AND_YEAR }} account. Changing this does not affect your {{ c.OIDC_ACCOUNT_NAME }} account email or login.</p>
6162
</div>
6263
</div>
@@ -71,7 +72,7 @@ <h4 class="modal-title" id="account_settings_title">
7172
<div class="row g-3 mb-3">
7273
<div class="col-sm">
7374
<label for="email" class="form-text">Account Email</label>
74-
<input type="email" name="account_email" id="account_email" value="{{ homepage_account.email }}" class="form-control" placeholder="Account email address" required>
75+
<input type="email" name="account_email" id="account_email" value="{{ account.email }}" class="form-control" placeholder="Account email address" required>
7576
</div>
7677
</div>
7778
<div class="row g-3 mb-3">

0 commit comments

Comments
 (0)