From 2a9a81d88d00c475e6d6ff9b50cee5a63d322b27 Mon Sep 17 00:00:00 2001 From: keannu125 Date: Fri, 10 Mar 2023 23:09:20 +0800 Subject: [PATCH] Move sensitive info to .env file and reset db --- Pipfile | 1 + Pipfile.lock | 10 +++++++++- ivy/config/settings.py | 22 ++++++++++++++++------ 3 files changed, 26 insertions(+), 7 deletions(-) diff --git a/Pipfile b/Pipfile index 97b62ac..9eb4ced 100644 --- a/Pipfile +++ b/Pipfile @@ -10,6 +10,7 @@ djoser = "*" djangorestframework-simplejwt = "*" django-cors-headers = "*" django-simple-history = "*" +python-dotenv = "*" [dev-packages] autopep8 = "*" diff --git a/Pipfile.lock b/Pipfile.lock index 3a35af2..091fba6 100644 --- a/Pipfile.lock +++ b/Pipfile.lock @@ -1,7 +1,7 @@ { "_meta": { "hash": { - "sha256": "c580f89f813a209d5a47c10bda8969d741b957744084b178bd0a13d6f43e96ea" + "sha256": "adf075ae1c44614e471a3fde436359004437d32d0736e88bc3cfc79f626de919" }, "pipfile-spec": 6, "requires": { @@ -390,6 +390,14 @@ "markers": "python_version >= '3.7'", "version": "==2.6.0" }, + "python-dotenv": { + "hashes": [ + "sha256:a8df96034aae6d2d50a4ebe8216326c61c3eb64836776504fcca410e5937a3ba", + "sha256:f5971a9226b701070a4bf2c38c89e5a3f0d64de8debda981d1db98583009122a" + ], + "index": "pypi", + "version": "==1.0.0" + }, "python3-openid": { "hashes": [ "sha256:33fbf6928f401e0b790151ed2b5290b02545e8775f982485205a066f874aaeaf", diff --git a/ivy/config/settings.py b/ivy/config/settings.py index 269371c..e94716b 100644 --- a/ivy/config/settings.py +++ b/ivy/config/settings.py @@ -11,6 +11,10 @@ https://docs.djangoproject.com/en/4.1/ref/settings/ """ from pathlib import Path +from dotenv import load_dotenv +import os + +load_dotenv() # Build paths inside the project like this: BASE_DIR / 'subdir'. BASE_DIR = Path(__file__).resolve().parent.parent @@ -20,8 +24,7 @@ BASE_DIR = Path(__file__).resolve().parent.parent # See https://docs.djangoproject.com/en/4.1/howto/deployment/checklist/ # SECURITY WARNING: keep the secret key used in production secret! -SECRET_KEY = 'django-insecure-t&s%wwbx-78$qa#&id_+xw8!m3jt35bgukr03e@$v8$-x5q52i' - +SECRET_KEY = os.environ.get('SECRET_KEY') # SECURITY WARNING: don't run with debug turned on in production! DEBUG = True @@ -149,10 +152,17 @@ DJOSER = { }, } -EMAIL_HOST = 'sandbox.smtp.mailtrap.io' -EMAIL_HOST_USER = '54ff6949e39105' -EMAIL_HOST_PASSWORD = 'c59d3eaa05f98d' -EMAIL_PORT = '2525' +# Mailtrap SMTP Testing +# EMAIL_HOST = 'sandbox.smtp.mailtrap.io' +# EMAIL_HOST_USER = '54ff6949e39105' +# EMAIL_HOST_PASSWORD = 'c59d3eaa05f98d' +# EMAIL_PORT = '2525' + +EMAIL_HOST = "smtp.gmail.com" +EMAIL_HOST_USER = os.environ.get("EMAIL_HOST_USER") +EMAIL_HOST_PASSWORD = os.environ.get('EMAIL_HOST_PASSWORD') +EMAIL_PORT = 587 +EMAIL_USE_TLS = True CORS_ALLOWED_ORIGINS = [ "http://localhost:3000",