Compare commits

..

2 Commits

Author SHA1 Message Date
7342516ce7 Fixed mail sending 2024-03-14 22:13:52 +01:00
c310586fca Added sample .env 2024-03-14 22:13:27 +01:00
4 changed files with 30 additions and 10 deletions

22
.env.example Normal file
View File

@ -0,0 +1,22 @@
# TODO Fill me up
HOST=
PORT=
MYSQL_USER=
MYSQL_DATABASE=
MYSQL_HOST=
MYSQL_PORT=
MYSQL_PASSWORD=
REDIS_HOST=
REDIS_PORT=
JWT_SECRET_KEY=
MAIL_SERVER=
MAIL_PORT=
MAIL_USERNAME=
MAIL_PASSWORD=
MAIL_USE_TLS=
MAIL_DEFAULT_SENDER=

View File

@ -6,8 +6,11 @@ from flasgger import Swagger
from app.doc.main_swag import main_swagger
app = Flask(__name__)
jwt_manager = JWTManager(app)
from app.config import FlaskTesting, FlaskProduction
app.config.from_object(FlaskTesting)
mail = Mail(app)
jwt_manager = JWTManager(app)
swag = Swagger(app, template=main_swagger)
def create_app():
@ -18,9 +21,6 @@ def create_app():
app.register_blueprint(bp_user)
app.register_blueprint(bp_cart)
from app.config import FlaskTesting, FlaskProduction
app.config.from_object(FlaskTesting)
from . import jwt_utils
return app

View File

@ -22,7 +22,8 @@ class FlaskTesting:
SERVER_NAME = os.environ.get('HOST') + ':' + os.environ.get('PORT')
MAIL_SERVER = os.environ.get('MAIL_SERVER')
MAIL_PORT = os.environ.get('MAIL_USERNAME')
MAIL_PORT = os.environ.get('MAIL_PORT')
MAIL_USERNAME = os.environ.get('MAIL_USERNAME')
MAIL_PASSWORD = os.environ.get('MAIL_PASSWORD')
MAIL_USE_TLS = os.environ.get('MAIL_USE_TLS')
MAIL_USE_TLS = os.environ.get('MAIL_USE_TLS')
MAIL_DEFAULT_SENDER = os.environ.get('MAIL_DEFAULT_SENDER')

View File

@ -62,10 +62,7 @@ class UserService:
print(f"Error: {e}")
return {"Failed": "Failed to insert into database. Username or email are likely in use already"}, 500
# TODO Implement mail sending
# Currently throws error - connection refused
# send_mail("Successfully registered!", email, "Congratulations! Your account has been successfully created.\nThis mail also serves as a test that the email address is correct")
send_mail("Successfully registered!", email, "Congratulations! Your account has been successfully created.\nThis mail also serves as a test that the email address is correct")
return {"Success": "User created successfully"}, 200