Skip to content

Commit ef6a821

Browse files
committed
fix email validation in entrypoint.sh
Introduces a GLOBALLY_DELIVERABLE variable so that it can be passed to the email validator library and ultimately allowing the email admin@localhost to be valid, as long as False is passed in. Also: * adjusted the indentation of a command above it in the entrypoint.sh * added printing out the output of the validation library so that we can better find what the actual issue is
1 parent 92c9e59 commit ef6a821

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

pkg/docker/entrypoint.sh

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,11 +87,16 @@ if [ ! -f /var/lib/pgadmin/pgadmin4.db ] && [ "${external_config_db_exists}" = "
8787
if [ -n "${PGADMIN_CONFIG_ALLOW_SPECIAL_EMAIL_DOMAINS}" ]; then
8888
ALLOW_SPECIAL_EMAIL_DOMAINS=${PGADMIN_CONFIG_ALLOW_SPECIAL_EMAIL_DOMAINS}
8989
fi
90-
email_config="{'CHECK_EMAIL_DELIVERABILITY': ${CHECK_EMAIL_DELIVERABILITY}, 'ALLOW_SPECIAL_EMAIL_DOMAINS': ${ALLOW_SPECIAL_EMAIL_DOMAINS}}"
91-
echo "email config is ${email_config}"
90+
GLOBALLY_DELIVERABLE="True"
91+
if [ -n "${PGADMIN_CONFIG_GLOBALLY_DELIVERABLE}" ]; then
92+
GLOBALLY_DELIVERABLE=${PGADMIN_CONFIG_GLOBALLY_DELIVERABLE}
93+
fi
94+
email_config="{'CHECK_EMAIL_DELIVERABILITY': ${CHECK_EMAIL_DELIVERABILITY}, 'ALLOW_SPECIAL_EMAIL_DOMAINS': ${ALLOW_SPECIAL_EMAIL_DOMAINS}, 'GLOBALLY_DELIVERABLE': ${GLOBALLY_DELIVERABLE}}"
95+
echo "email config is ${email_config}"
9296
is_valid_email=$(cd /pgadmin4/pgadmin/utils && /venv/bin/python3 -c "from validation_utils import validate_email; val = validate_email('${PGADMIN_DEFAULT_EMAIL}', ${email_config}); print(val)")
9397
if echo "${is_valid_email}" | grep "False" > /dev/null; then
9498
echo "'${PGADMIN_DEFAULT_EMAIL}' does not appear to be a valid email address. Please reset the PGADMIN_DEFAULT_EMAIL environment variable and try again."
99+
echo "Validation output: ${is_valid_email}"
95100
exit 1
96101
fi
97102
# Switch back to root directory for further process

web/pgadmin/utils/validation_utils.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ def validate_email(email, email_config=None):
2121
config.CHECK_EMAIL_DELIVERABILITY
2222
email_config['ALLOW_SPECIAL_EMAIL_DOMAINS'] = \
2323
config.ALLOW_SPECIAL_EMAIL_DOMAINS
24+
email_config["GLOBALLY_DELIVERABLE"] = \
25+
config.GLOBALLY_DELIVERABLE
2426

2527
# Allow special email domains
2628
if isinstance(email_config['ALLOW_SPECIAL_EMAIL_DOMAINS'], str):
@@ -35,6 +37,9 @@ def validate_email(email, email_config=None):
3537
except Exception:
3638
pass
3739

40+
email_validator.GLOBALLY_DELIVERABLE = \
41+
email_config["GLOBALLY_DELIVERABLE"]
42+
3843
# Validate.
3944
_ = email_validate(
4045
email,

0 commit comments

Comments
 (0)