diff --git a/README.md b/README.md index 6904c2b..ae52447 100644 --- a/README.md +++ b/README.md @@ -54,17 +54,18 @@ Here is a summary of the configuration options available in the `docker-compose. ### Backend Container (server) -| Name | Required | Description | Default Value | -| ----------------------- | -------- | -------------------------------------------------------------------------------------------------------------------------------------------- | -------------------- | -| `PGHOST` | Yes | Databse host. | db | -| `PGDATABASE` | Yes | Database. | database | -| `PGUSER` | Yes | Database user. | adventure | -| `PGPASSWORD` | Yes | Database password. | changeme123 | -| `DJANGO_ADMIN_USERNAME` | Yes | Default username. | admin | -| `DJANGO_ADMIN_PASSWORD` | Yes | Default password, change after inital login. | admin | -| `DJANGO_ADMIN_EMAIL` | Yes | Default user's email. | admin@example.com | -| `PUBLIC_URL` | Yes | This is the publically accessible url to the **nginx** container. You should be able to acess nginx from this url where you access your app. | http://127.0.0.1:81 | -| `CSRF_TRUSTED_ORIGINS` | Yes | Need to be changed to the orgins where you use your backend server and frontend. These values are comma seperated. | Needs to be changed. | +| Name | Required | Description | Default Value | +| ----------------------- | -------- | --------------------------------------------------------------------------------------------------------------------------------------------- | --------------------- | +| `PGHOST` | Yes | Databse host. | db | +| `PGDATABASE` | Yes | Database. | database | +| `PGUSER` | Yes | Database user. | adventure | +| `PGPASSWORD` | Yes | Database password. | changeme123 | +| `DJANGO_ADMIN_USERNAME` | Yes | Default username. | admin | +| `DJANGO_ADMIN_PASSWORD` | Yes | Default password, change after inital login. | admin | +| `DJANGO_ADMIN_EMAIL` | Yes | Default user's email. | admin@example.com | +| `PUBLIC_URL` | Yes | This is the publically accessible url to the **nginx** container. You should be able to acess nginx from this url where you access your app. | http://127.0.0.1:81 | +| `CSRF_TRUSTED_ORIGINS` | Yes | Need to be changed to the orgins where you use your backend server and frontend. These values are comma seperated. | Needs to be changed. | +| `FRONTEND_URL` | Yes | This is the publically accessible url to the **frontend** container. This link should be accessable for all users. Used for email generation. | http://localhost:3000 | ### Proxy Container (nginx) Configuration diff --git a/backend/server/.env.example b/backend/server/.env.example index ea63047..04eb77f 100644 --- a/backend/server/.env.example +++ b/backend/server/.env.example @@ -7,4 +7,17 @@ SECRET_KEY='pleasechangethisbecauseifyoudontitwillbeverybadandyouwillgethackedin PUBLIC_URL='http://127.0.0.1:8000' -DEBUG=True \ No newline at end of file +DEBUG=True + +FRONTEND_URL='http://localhost:3000' + +EMAIL_BACKEND='console' + +# EMAIL_BACKEND='email' +# EMAIL_HOST='smtp.gmail.com' +# EMAIL_USE_TLS=False +# EMAIL_PORT=587 +# EMAIL_USE_SSL=True +# EMAIL_HOST_USER='user' +# EMAIL_HOST_PASSWORD='password' +# DEFAULT_FROM_EMAIL='user@example.com' \ No newline at end of file diff --git a/backend/server/main/settings.py b/backend/server/main/settings.py index 3df32e2..18522ed 100644 --- a/backend/server/main/settings.py +++ b/backend/server/main/settings.py @@ -169,7 +169,7 @@ STORAGES = { AUTH_USER_MODEL = 'users.CustomUser' -FRONTEND_URL = 'http://localhost:5173' +FRONTEND_URL = getenv('FRONTEND_URL', 'http://localhost:3000') EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend' SITE_ID = 1 @@ -177,6 +177,18 @@ ACCOUNT_EMAIL_REQUIRED = True ACCOUNT_AUTHENTICATION_METHOD = 'username' ACCOUNT_EMAIL_VERIFICATION = 'optional' +if getenv('EMAIL_BACKEND', 'console') == 'console': + EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend' +else: + EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend' + EMAIL_HOST = getenv('EMAIL_HOST') + EMAIL_USE_TLS = getenv('EMAIL_USE_TLS', 'True') == 'True' + EMAIL_PORT = getenv('EMAIL_PORT', 587) + EMAIL_USE_SSL = getenv('EMAIL_USE_SSL', 'False') == 'True' + EMAIL_HOST_USER = getenv('EMAIL_HOST_USER') + EMAIL_HOST_PASSWORD = getenv('EMAIL_HOST_PASSWORD') + DEFAULT_FROM_EMAIL = getenv('DEFAULT_FROM_EMAIL') + # EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend' # EMAIL_HOST = 'smtp.resend.com' # EMAIL_USE_TLS = False diff --git a/backend/server/templates/account/email/password_reset_key_message.txt b/backend/server/templates/account/email/password_reset_key_message.txt index 1716b1d..42473bf 100644 --- a/backend/server/templates/account/email/password_reset_key_message.txt +++ b/backend/server/templates/account/email/password_reset_key_message.txt @@ -3,7 +3,7 @@ {% block content %}{% autoescape off %}{% blocktrans %}You're receiving this email because you or someone else has requested a password reset for your user account. -It can be safely ignored if you did not request a password reset. Click the link below to reset your password. TEST FOR AdventurELOG{% endblocktrans %} +It can be safely ignored if you did not request a password reset. Click the link below to reset your password.{% endblocktrans %} {{ frontend_url }}/settings/forgot-password/confirm?token={{ temp_key }}&uid={{ user_pk }} diff --git a/docker-compose.yml b/docker-compose.yml index 375bad0..a6df3fa 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -38,6 +38,7 @@ services: - PUBLIC_URL='http://localhost:81' - CSRF_TRUSTED_ORIGINS=https://api.adventurelog.app,https://adventurelog.app - DEBUG=False + - FRONTEND_URL='http://localhost:8080' ports: - "8000:8000" depends_on: diff --git a/documentation/docs/Installation/docker.md b/documentation/docs/Installation/docker.md index d2236fb..0c12fde 100644 --- a/documentation/docs/Installation/docker.md +++ b/documentation/docs/Installation/docker.md @@ -35,17 +35,18 @@ Here is a summary of the configuration options available in the `docker-compose. ### Backend Container (server) -| Name | Required | Description | Default Value | -| ----------------------- | -------- | -------------------------------------------------------------------------------------------------------------------------------------------- | -------------------- | -| `PGHOST` | Yes | Databse host. | db | -| `PGDATABASE` | Yes | Database. | database | -| `PGUSER` | Yes | Database user. | adventure | -| `PGPASSWORD` | Yes | Database password. | changeme123 | -| `DJANGO_ADMIN_USERNAME` | Yes | Default username. | admin | -| `DJANGO_ADMIN_PASSWORD` | Yes | Default password, change after inital login. | admin | -| `DJANGO_ADMIN_EMAIL` | Yes | Default user's email. | admin@example.com | -| `PUBLIC_URL` | Yes | This is the publically accessible url to the **nginx** container. You should be able to acess nginx from this url where you access your app. | http://127.0.0.1:81 | -| `CSRF_TRUSTED_ORIGINS` | Yes | Need to be changed to the orgins where you use your backend server and frontend. These values are comma seperated. | Needs to be changed. | +| Name | Required | Description | Default Value | +| ----------------------- | -------- | --------------------------------------------------------------------------------------------------------------------------------------------- | --------------------- | +| `PGHOST` | Yes | Databse host. | db | +| `PGDATABASE` | Yes | Database. | database | +| `PGUSER` | Yes | Database user. | adventure | +| `PGPASSWORD` | Yes | Database password. | changeme123 | +| `DJANGO_ADMIN_USERNAME` | Yes | Default username. | admin | +| `DJANGO_ADMIN_PASSWORD` | Yes | Default password, change after inital login. | admin | +| `DJANGO_ADMIN_EMAIL` | Yes | Default user's email. | admin@example.com | +| `PUBLIC_URL` | Yes | This is the publically accessible url to the **nginx** container. You should be able to acess nginx from this url where you access your app. | http://127.0.0.1:81 | +| `CSRF_TRUSTED_ORIGINS` | Yes | Need to be changed to the orgins where you use your backend server and frontend. These values are comma seperated. | Needs to be changed. | +| `FRONTEND_URL` | Yes | This is the publically accessible url to the **frontend** container. This link should be accessable for all users. Used for email generation. | http://localhost:3000 | ### Proxy Container (nginx) Configuration