diff --git a/dist.env b/dist.env index 8b7ba78..14b7b04 100644 --- a/dist.env +++ b/dist.env @@ -14,10 +14,12 @@ POSTGRES_DB=forest_prod PGADMIN_DEFAULT_EMAIL=mail@example.com PGADMIN_DEFAULT_PASSWORD=hackme -MAIL_ADMIN=mail@example.com +MAIL_SENDER=mail@example.com MAIL_SUBJECT_PREFIX=ForestNet MAIL_SERVER=smtp.gmail.com MAIL_USERNAME=admin@gmail.com MAIL_PASSWORD=kur MAIL_PORT=25 MAIL_USE_TLS=1 + +ADMIN_MAIL=mail@example.com diff --git a/src/forest/config.py b/src/forest/config.py index 96f0915..f1db4c9 100644 --- a/src/forest/config.py +++ b/src/forest/config.py @@ -1,9 +1,7 @@ import os - basedir = os.path.abspath(os.path.dirname(__file__)) - class Config(object): SECRET_KEY = f"{os.getenv('SECRET_KEY')}" RECAPTCHA_PUBLIC_KEY = f"{os.getenv('RECAPTCHA_PUBLIC_KEY')}" @@ -13,10 +11,11 @@ class Config(object): STATIC_FOLDER = f"{os.getenv('APP_HOME')}/forest/static" MEDIA_FOLDER = f"{os.getenv('APP_HOME')}/forest/media" ADMIN_PREFIX = "fadmin" + MAIL_SENDER = f"{os.getenv('MAIL_SENDER')}" MAIL_SERVER = f"{os.getenv('MAIL_SERVER')}" MAIL_USERNAME = f"{os.getenv('MAIL_USERNAME')}" MAIL_PASSWORD = f"{os.getenv('MAIL_PASSWORD')}" MAIL_PORT = f"{os.getenv('MAIL_PORT')}" MAIL_SUBJECT_PREFIX = f"{os.getenv('MAIL_SUBJECT_PREFIX')}" - MAIL_ADMIN = f"{os.getenv('MAIL_ADMIN')}" MAIL_USE_TLS = f"{os.getenv('MAIL_USE_TLS')}" + ADMIN_MAIL = f"{os.getenv('ADMIN_MAIL')}" diff --git a/src/forest/mailsender.py b/src/forest/mailsender.py index 26ae430..7b2d143 100644 --- a/src/forest/mailsender.py +++ b/src/forest/mailsender.py @@ -16,7 +16,7 @@ def send_email(to, subject, template, **kwargs): else: newsubject = subject app = current_app._get_current_object() - msg = Message(app.config['MAIL_SUBJECT_PREFIX'] + ' ' + newsubject, sender=app.config['MAIL_ADMIN'], recipients=[to]) + msg = Message(app.config['MAIL_SUBJECT_PREFIX'] + ' ' + newsubject, sender=app.config['MAIL_SENDER'], recipients=[to]) msg.body = render_template(template + '.txt', **kwargs) msg.html = render_template(template + '.html', **kwargs) thr = Thread(target=send_async_email, args=[app, msg]) diff --git a/src/forest/models.py b/src/forest/models.py index 7613c57..f837f26 100644 --- a/src/forest/models.py +++ b/src/forest/models.py @@ -88,7 +88,7 @@ class User(db.Model, UserMixin): super(User, self).__init__(**kwargs) if self.role is None: - if self.email == current_app.config['MAIL_ADMIN']: + if self.email == current_app.config['ADMIN_MAIL']: #if email match config admin name create admin user self.role = Role.query.filter_by(permissions=0xff).first() if self.role is None: