Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update MAIL configuration for 3rd party mail service. #46

Merged
merged 27 commits into from
Oct 8, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
41fcaa9
stub out index html
MekWarrior Jul 24, 2020
0449fba
remove duplicates at wrong level and add partials
MekWarrior Jul 29, 2020
ec899cb
Merge branch 'master' into html_buildout
MekWarrior Jul 29, 2020
83241be
move static files to correct level and start forms for experiments
MekWarrior Jul 29, 2020
96211bb
move files to match preferred layout
MekWarrior Jul 30, 2020
48e949a
first attempt at data entry page
MekWarrior Jul 30, 2020
5b6051f
refining connections for the new form
MekWarrior Jul 31, 2020
4d965b0
Fix template routing and PEP8 changes (#34)
willgraf Jul 31, 2020
f9edbfd
change form format
MekWarrior Jul 31, 2020
e6373e7
Merge branch 'html_buildout' of https://github.com/vanvalenlab/deepce…
MekWarrior Jul 31, 2020
3404a88
Override flask-security login templates and add links to navbar. (#35)
willgraf Aug 3, 2020
5493227
experiement with different data entry layouts
MekWarrior Aug 3, 2020
9db6fb0
Merge branch 'html_buildout' of https://github.com/vanvalenlab/deepce…
MekWarrior Aug 3, 2020
c6daa5d
add back in changes lost in merge conflicts
MekWarrior Aug 3, 2020
74a36a1
initialize the mail application
willgraf Aug 3, 2020
2059d51
add all flask-mail configuration settings as environment variables to…
willgraf Aug 3, 2020
6284bbb
add a mailserver container to docker-compose.
willgraf Aug 3, 2020
299964e
enable flask-security settings that use the mail client.
willgraf Aug 3, 2020
cb31b62
Merge branch 'master' into flask-mail
willgraf Oct 2, 2020
6fca8c9
remove outdated routes
willgraf Oct 2, 2020
a9d24d7
set MAIL_TLS to True by default, and MAIL_PORT to 587 for TLS.
willgraf Oct 2, 2020
addf116
Remove docker-compose mailserver (didn't work)
willgraf Oct 2, 2020
dd7b17e
Include default MAIL_USERNAME and MAIL_PASSWORD in docker-compose
willgraf Oct 2, 2020
0f299cd
Updaet domain of default sender.
willgraf Oct 2, 2020
5d7e0e7
turn on email features if MAIL_SERVER is not the default value.
willgraf Oct 2, 2020
1c38f34
remove unwanted changes.
willgraf Oct 2, 2020
9a0915a
pin pytest<6 to fix compatibility with pytest-pep8
willgraf Oct 2, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions deepcell_datasets/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
"""DeepCell Datasets Module"""

from flask import Flask
from flask_mail import Mail
from flask_security import Security, hash_password
# from flask_debugtoolbar import DebugToolbarExtension

Expand Down Expand Up @@ -63,6 +64,10 @@ def create_app(**config_overrides):

database.db.initialize_db(app)

# Setup Flask-Mail
mail = Mail()
mail.init_app(app)

# Setup Flask-Security
security = Security()
security.init_app(app, database.models.user_datastore)
Expand Down
18 changes: 14 additions & 4 deletions deepcell_datasets/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,16 @@

TEMPLATES_AUTO_RELOAD = decouple.config('TEMPLATES_AUTO_RELOAD', cast=bool, default=True)

# Flask-Mail settings: https://tinyurl.com/y3db5s3h
MAIL_SERVER = decouple.config('MAIL_SERVER', default='localhost')
MAIL_PORT = decouple.config('MAIL_PORT', default=587, cast=int)
MAIL_USE_TLS = decouple.config('MAIL_USE_TLS', default=True, cast=bool)
MAIL_USE_SSL = decouple.config('MAIL_USE_SSL', default=False, cast=bool)
MAIL_USERNAME = decouple.config('MAIL_USERNAME', default=None)
MAIL_PASSWORD = decouple.config('MAIL_PASSWORD', default=None)
MAIL_DEFAULT_SENDER = decouple.config('MAIL_DEFAULT_SENDER', default='[email protected]')
MAIL_MAX_EMAILS = decouple.config('MAIL_MAX_EMAILS', default=None)

# Flask-Security-Too settings: https://tinyurl.com/y5d2n9ry
# Generate a nice key using secrets.token_urlsafe()
SECRET_KEY = decouple.config('SECRET_KEY', default='super-secret')
Expand All @@ -41,15 +51,15 @@
SECURITY_PASSWORD_SALT = decouple.config('SECURITY_PASSWORD_SALT', default='salt')
# Enable new users to create accounts
SECURITY_REGISTERABLE = True
SECURITY_SEND_REGISTER_EMAIL = False # TODO: need to set up a mail client if True.
SECURITY_SEND_REGISTER_EMAIL = MAIL_SERVER != 'localhost'
# Enable users to reset/recover their password
SECURITY_RECOVERABLE = False # TODO: need to set up a mail client if True.
SECURITY_RECOVERABLE = MAIL_SERVER != 'localhost'
SECURITY_RESET_PASSWORD_WITHIN = '3 days'
# Enable users to change their password
SECURITY_CHANGEABLE = True
SECURITY_SEND_PASSWORD_CHANGE_EMAIL = False # TODO: need to set up a mail client if True.
SECURITY_SEND_PASSWORD_CHANGE_EMAIL = MAIL_SERVER != 'localhost'
# Send an confirmation email, but allow login without it
SECURITY_CONFIRMABLE = False # TODO: need to set up a mail client if True.
SECURITY_CONFIRMABLE = MAIL_SERVER != 'localhost'
SECURITY_LOGIN_WITHOUT_CONFIRMATION = True
# Tracks basic user login statistics
SECURITY_TRACKABLE = True
Expand Down
4 changes: 4 additions & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ services:
MONGODB_PORT: ${MONGODB_PORT:-27017}
# MONGODB_USERNAME: ${MONGODB_USERNAME:-root}
# MONGODB_PASSWORD: ${MONGODB_PASSWORD:-password}
MAIL_SERVER: ${MAIL_SERVER:-locahost}
MAIL_PORT: ${MAIL_PORT:-587}
MAIL_USERNAME: ${MAIL_USERNAME:[email protected]}
MAIL_PASSWORD: ${MAIL_PASSWORD:-password}

mongo:
image: mongo
Expand Down
2 changes: 1 addition & 1 deletion requirements-test.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pytest
pytest<6
pytest-cov
pytest-pep8
mongomock
Expand Down