Flip country config check in template

Country config value should be checked against the valid value when
updating the home page config, not the other way around. This can lead
to a state where a user sets up an invalid country value, but can still
be matched against a correct value that is part of the invalid value
(i.e. "countryUK" is invalid, but would match against the correct value,
"UK")

Also minor refactor of where the session file size validation occurs.
main
Ben Busby 2022-06-16 12:11:23 -06:00
parent cb5557cc2e
commit ddc73a53fe
No known key found for this signature in database
GPG Key ID: B9B7231E01D924A1
2 changed files with 8 additions and 8 deletions

View File

@ -70,21 +70,21 @@ def session_required(f):
# Clear out old sessions
invalid_sessions = []
for user_session in os.listdir(app.config['SESSION_FILE_DIR']):
session_path = os.path.join(
file_path = os.path.join(
app.config['SESSION_FILE_DIR'],
user_session)
# Ignore any files that are larger than the max session file size
if os.path.getsize(session_path) > app.config['MAX_SESSION_SIZE']:
try:
# Ignore files that are larger than the max session file size
if os.path.getsize(file_path) > app.config['MAX_SESSION_SIZE']:
continue
try:
with open(session_path, 'rb') as session_file:
with open(file_path, 'rb') as session_file:
_ = pickle.load(session_file)
data = pickle.load(session_file)
if isinstance(data, dict) and 'valid' in data:
continue
invalid_sessions.append(session_path)
invalid_sessions.append(file_path)
except (EOFError, FileNotFoundError, pickle.UnpicklingError):
pass

View File

@ -93,7 +93,7 @@
<select name="country" id="config-country">
{% for country in countries %}
<option value="{{ country.value }}"
{% if country.value in config.country %}
{% if config.country in country.value %}
selected
{% endif %}>
{{ country.name }}