From 66cf424993eaaa62a04c7019a9075c833067d037 Mon Sep 17 00:00:00 2001 From: Adam Sutton Date: Tue, 2 Jan 2024 14:38:11 +0000 Subject: [PATCH 01/11] frontend changes for forgotten password functionality --- .../frontend/src/components/common/Login.vue | 26 ++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/webapp/frontend/src/components/common/Login.vue b/webapp/frontend/src/components/common/Login.vue index 2b048f2a..bbfedc39 100644 --- a/webapp/frontend/src/components/common/Login.vue +++ b/webapp/frontend/src/components/common/Login.vue @@ -7,9 +7,14 @@ +
Forgotten Password
Username and/or password incorrect Cannot determine admin status of username +
+ + +
@@ -40,7 +45,8 @@ export default { uname: '', password: '', failed: false, - failedAdminStatusCheck: false + failedAdminStatusCheck: false, + forgottenPassword: false } }, methods: { @@ -81,6 +87,13 @@ export default { if (e.keyCode === 13 && this.uname.length > 0 && this.password.length > 0) { this.login() } + }, + reset_password () { + let payload = { + username: this.uname + } + + instance.post('/api/api-reset-password/', payload, {}) } }, created () { @@ -102,4 +115,15 @@ export default { width: 400px; } } + +.forgotten { + cursor:pointer; + color:blue; + text-decoration:underline; +} + +.forgotten:hover { + cursor:pointer; +} + From 30c790a826fc2d2296fb14670a93327b02218e3c Mon Sep 17 00:00:00 2001 From: Adam Sutton Date: Wed, 3 Jan 2024 23:10:01 +0000 Subject: [PATCH 02/11] added password reset functionality --- webapp/api/core/settings.py | 10 ++++++++++ webapp/api/core/urls.py | 6 +++++- webapp/frontend/src/components/common/Login.vue | 9 ++------- 3 files changed, 17 insertions(+), 8 deletions(-) diff --git a/webapp/api/core/settings.py b/webapp/api/core/settings.py index 00b938a8..14e42e5e 100644 --- a/webapp/api/core/settings.py +++ b/webapp/api/core/settings.py @@ -192,3 +192,13 @@ SOLR_PORT = os.environ.get('CONCEPT_SEARCH_SERVICE_PORT', '8983') SILENCED_SYSTEM_CHECKS = ['admin.E130'] + +# For testing only +# EMAIL_BACKEND = "django.core.mail.backends.console.EmailBackend" + +EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend' +EMAIL_HOST = 'smtp.gmail.com' +EMAIL_PORT = 587 +EMAIL_HOST_USER = os.environ.get('EMAIL_USER') +EMAIL_HOST_PASSWORD = os.environ.get('EMAIL_PASS') +EMAIL_USE_TLS = True \ No newline at end of file diff --git a/webapp/api/core/urls.py b/webapp/api/core/urls.py index a458e408..ea7a96af 100644 --- a/webapp/api/core/urls.py +++ b/webapp/api/core/urls.py @@ -14,12 +14,12 @@ 2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) """ from django.contrib import admin +from django.contrib.auth import views as pw_views from django.urls import path, include, re_path from rest_framework.authtoken import views as auth_views from rest_framework import routers import api.views - router = routers.DefaultRouter() router.register(r'users', api.views.UserViewSet) router.register(r'entities', api.views.EntityViewSet) @@ -70,5 +70,9 @@ path('api/concept-path/', api.views.cdb_concept_path), path('api/generate-concept-filter-json/', api.views.generate_concept_filter_flat_json), path('api/generate-concept-filter/', api.views.generate_concept_filter), + path('reset_password/', pw_views.PasswordResetView.as_view(), name ='reset_password'), + path('reset_password_sent/', pw_views.PasswordResetDoneView.as_view(), name ='password_reset_done'), + path('reset//', pw_views.PasswordResetConfirmView.as_view(), name ='password_reset_confirm'), + path('reset_password_complete/', pw_views.PasswordResetCompleteView.as_view(), name ='password_reset_complete'), re_path('^.*$', api.views.index, name='index'), # Match everything else to home ] diff --git a/webapp/frontend/src/components/common/Login.vue b/webapp/frontend/src/components/common/Login.vue index bbfedc39..183df1cd 100644 --- a/webapp/frontend/src/components/common/Login.vue +++ b/webapp/frontend/src/components/common/Login.vue @@ -7,14 +7,10 @@ -
Forgotten Password
+ Forgotten Password Username and/or password incorrect Cannot determine admin status of username -
- - -
@@ -45,8 +41,7 @@ export default { uname: '', password: '', failed: false, - failedAdminStatusCheck: false, - forgottenPassword: false + failedAdminStatusCheck: false } }, methods: { From 295966ecbd6d3a8e2347317c170aa2add8be0d05 Mon Sep 17 00:00:00 2001 From: Adam Sutton Date: Wed, 3 Jan 2024 23:17:55 +0000 Subject: [PATCH 03/11] removed styling no longer needed --- .../frontend/src/components/common/Login.vue | 18 +----------------- 1 file changed, 1 insertion(+), 17 deletions(-) diff --git a/webapp/frontend/src/components/common/Login.vue b/webapp/frontend/src/components/common/Login.vue index 183df1cd..c1a41da6 100644 --- a/webapp/frontend/src/components/common/Login.vue +++ b/webapp/frontend/src/components/common/Login.vue @@ -7,7 +7,7 @@ - Forgotten Password + Forgotten Password Username and/or password incorrect Cannot determine admin status of username @@ -82,13 +82,6 @@ export default { if (e.keyCode === 13 && this.uname.length > 0 && this.password.length > 0) { this.login() } - }, - reset_password () { - let payload = { - username: this.uname - } - - instance.post('/api/api-reset-password/', payload, {}) } }, created () { @@ -111,14 +104,5 @@ export default { } } -.forgotten { - cursor:pointer; - color:blue; - text-decoration:underline; -} - -.forgotten:hover { - cursor:pointer; -} From 42dee1096f5965308f2ec8f646a5db3125551bcc Mon Sep 17 00:00:00 2001 From: adam-sutton-1992 Date: Thu, 18 Jan 2024 17:17:14 +0000 Subject: [PATCH 04/11] added custom email message --- webapp/api/core/settings.py | 5 +++-- webapp/api/core/urls.py | 2 +- .../registration/password_reset_email.html | 17 +++++++++++++++++ .../registration/password_reset_subject.txt | 1 + 4 files changed, 22 insertions(+), 3 deletions(-) create mode 100644 webapp/templates/registration/password_reset_email.html create mode 100644 webapp/templates/registration/password_reset_subject.txt diff --git a/webapp/api/core/settings.py b/webapp/api/core/settings.py index 14e42e5e..39e639c5 100644 --- a/webapp/api/core/settings.py +++ b/webapp/api/core/settings.py @@ -75,6 +75,7 @@ 'BACKEND': 'django.template.backends.django.DjangoTemplates', 'DIRS': [ os.path.join(BASE_DIR, "..", "frontend", "dist"), + os.path.join(BASE_DIR, "..", "templates", "registration") ], 'APP_DIRS': True, 'OPTIONS': { @@ -199,6 +200,6 @@ EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend' EMAIL_HOST = 'smtp.gmail.com' EMAIL_PORT = 587 -EMAIL_HOST_USER = os.environ.get('EMAIL_USER') -EMAIL_HOST_PASSWORD = os.environ.get('EMAIL_PASS') +EMAIL_HOST_USER = 'sutton.adam04@gmail.com' +EMAIL_HOST_PASSWORD = 'rrwt ohso fpin swhi' EMAIL_USE_TLS = True \ No newline at end of file diff --git a/webapp/api/core/urls.py b/webapp/api/core/urls.py index ea7a96af..55968447 100644 --- a/webapp/api/core/urls.py +++ b/webapp/api/core/urls.py @@ -70,7 +70,7 @@ path('api/concept-path/', api.views.cdb_concept_path), path('api/generate-concept-filter-json/', api.views.generate_concept_filter_flat_json), path('api/generate-concept-filter/', api.views.generate_concept_filter), - path('reset_password/', pw_views.PasswordResetView.as_view(), name ='reset_password'), + path('reset_password/', pw_views.PasswordResetView.as_view(email_template_name="password_reset_email.html", subject_template_name="password_reset_subject.txt"), name ='reset_password'), path('reset_password_sent/', pw_views.PasswordResetDoneView.as_view(), name ='password_reset_done'), path('reset//', pw_views.PasswordResetConfirmView.as_view(), name ='password_reset_confirm'), path('reset_password_complete/', pw_views.PasswordResetCompleteView.as_view(), name ='password_reset_complete'), diff --git a/webapp/templates/registration/password_reset_email.html b/webapp/templates/registration/password_reset_email.html new file mode 100644 index 00000000..dda38a8a --- /dev/null +++ b/webapp/templates/registration/password_reset_email.html @@ -0,0 +1,17 @@ +{% autoescape off %} +You’re receiving this email because you requested a password reset for your user account +with MedCATTrainer at {{ site_name }}. + +Please go to the following page and choose a new password: + +{{ protocol }}://{{ domain }}{% url 'password_reset_confirm' uidb64=uid token=token %} + +Your username, in case you've forgotten: {{ user.username }}. + +If clicking the link above doesn't work, please copy and paste the URL in a new browser +window instead. + +Sincerely, + +The Cogstack Team +{% endautoescape %} \ No newline at end of file diff --git a/webapp/templates/registration/password_reset_subject.txt b/webapp/templates/registration/password_reset_subject.txt new file mode 100644 index 00000000..7147d40b --- /dev/null +++ b/webapp/templates/registration/password_reset_subject.txt @@ -0,0 +1 @@ +MedCATtrainer: Password Reset \ No newline at end of file From aa5e1b1a08d90d35be304acaef756b8b54fcc242 Mon Sep 17 00:00:00 2001 From: adam-sutton-1992 Date: Thu, 18 Jan 2024 17:17:14 +0000 Subject: [PATCH 05/11] added custom email message --- webapp/api/core/settings.py | 1 + webapp/api/core/urls.py | 2 +- .../registration/password_reset_email.html | 17 +++++++++++++++++ .../registration/password_reset_subject.txt | 1 + 4 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 webapp/templates/registration/password_reset_email.html create mode 100644 webapp/templates/registration/password_reset_subject.txt diff --git a/webapp/api/core/settings.py b/webapp/api/core/settings.py index 14e42e5e..29b4789b 100644 --- a/webapp/api/core/settings.py +++ b/webapp/api/core/settings.py @@ -75,6 +75,7 @@ 'BACKEND': 'django.template.backends.django.DjangoTemplates', 'DIRS': [ os.path.join(BASE_DIR, "..", "frontend", "dist"), + os.path.join(BASE_DIR, "..", "templates", "registration") ], 'APP_DIRS': True, 'OPTIONS': { diff --git a/webapp/api/core/urls.py b/webapp/api/core/urls.py index ea7a96af..55968447 100644 --- a/webapp/api/core/urls.py +++ b/webapp/api/core/urls.py @@ -70,7 +70,7 @@ path('api/concept-path/', api.views.cdb_concept_path), path('api/generate-concept-filter-json/', api.views.generate_concept_filter_flat_json), path('api/generate-concept-filter/', api.views.generate_concept_filter), - path('reset_password/', pw_views.PasswordResetView.as_view(), name ='reset_password'), + path('reset_password/', pw_views.PasswordResetView.as_view(email_template_name="password_reset_email.html", subject_template_name="password_reset_subject.txt"), name ='reset_password'), path('reset_password_sent/', pw_views.PasswordResetDoneView.as_view(), name ='password_reset_done'), path('reset//', pw_views.PasswordResetConfirmView.as_view(), name ='password_reset_confirm'), path('reset_password_complete/', pw_views.PasswordResetCompleteView.as_view(), name ='password_reset_complete'), diff --git a/webapp/templates/registration/password_reset_email.html b/webapp/templates/registration/password_reset_email.html new file mode 100644 index 00000000..dda38a8a --- /dev/null +++ b/webapp/templates/registration/password_reset_email.html @@ -0,0 +1,17 @@ +{% autoescape off %} +You’re receiving this email because you requested a password reset for your user account +with MedCATTrainer at {{ site_name }}. + +Please go to the following page and choose a new password: + +{{ protocol }}://{{ domain }}{% url 'password_reset_confirm' uidb64=uid token=token %} + +Your username, in case you've forgotten: {{ user.username }}. + +If clicking the link above doesn't work, please copy and paste the URL in a new browser +window instead. + +Sincerely, + +The Cogstack Team +{% endautoescape %} \ No newline at end of file diff --git a/webapp/templates/registration/password_reset_subject.txt b/webapp/templates/registration/password_reset_subject.txt new file mode 100644 index 00000000..7147d40b --- /dev/null +++ b/webapp/templates/registration/password_reset_subject.txt @@ -0,0 +1 @@ +MedCATtrainer: Password Reset \ No newline at end of file From d6585c6baabeeefd75fe36d78ab09d1ab7cbe3da Mon Sep 17 00:00:00 2001 From: adam-sutton-1992 Date: Thu, 18 Jan 2024 18:01:02 +0000 Subject: [PATCH 06/11] removed unnessescary information --- webapp/api/core/settings.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/webapp/api/core/settings.py b/webapp/api/core/settings.py index 39e639c5..29b4789b 100644 --- a/webapp/api/core/settings.py +++ b/webapp/api/core/settings.py @@ -200,6 +200,6 @@ EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend' EMAIL_HOST = 'smtp.gmail.com' EMAIL_PORT = 587 -EMAIL_HOST_USER = 'sutton.adam04@gmail.com' -EMAIL_HOST_PASSWORD = 'rrwt ohso fpin swhi' +EMAIL_HOST_USER = os.environ.get('EMAIL_USER') +EMAIL_HOST_PASSWORD = os.environ.get('EMAIL_PASS') EMAIL_USE_TLS = True \ No newline at end of file From 92698f723d6dcf57234cda5faa65f366ae085074 Mon Sep 17 00:00:00 2001 From: Adam Sutton Date: Thu, 18 Jan 2024 18:11:03 +0000 Subject: [PATCH 07/11] remove unnessescary information --- webapp/api/core/settings.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/webapp/api/core/settings.py b/webapp/api/core/settings.py index 39e639c5..29b4789b 100644 --- a/webapp/api/core/settings.py +++ b/webapp/api/core/settings.py @@ -200,6 +200,6 @@ EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend' EMAIL_HOST = 'smtp.gmail.com' EMAIL_PORT = 587 -EMAIL_HOST_USER = 'sutton.adam04@gmail.com' -EMAIL_HOST_PASSWORD = 'rrwt ohso fpin swhi' +EMAIL_HOST_USER = os.environ.get('EMAIL_USER') +EMAIL_HOST_PASSWORD = os.environ.get('EMAIL_PASS') EMAIL_USE_TLS = True \ No newline at end of file From d882c15fcba986e372c11417cc49b97441815680 Mon Sep 17 00:00:00 2001 From: Adam Sutton Date: Fri, 19 Jan 2024 18:48:51 +0000 Subject: [PATCH 08/11] added custom SMTP error response --- webapp/api/api/views.py | 13 +++++++++++++ webapp/api/core/urls.py | 2 +- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/webapp/api/api/views.py b/webapp/api/api/views.py index ffb0ab11..3afca0e6 100644 --- a/webapp/api/api/views.py +++ b/webapp/api/api/views.py @@ -9,11 +9,13 @@ from django.shortcuts import render from django.utils import timezone from django_filters import rest_framework as drf +from django.contrib.auth.views import PasswordResetView from medcat.cdb import CDB from medcat.utils.helpers import tkns_from_doc from rest_framework import viewsets from rest_framework.decorators import api_view from rest_framework.response import Response +from smtplib import SMTPException from core.settings import MEDIA_ROOT from .admin import download_projects_with_text, download_projects_without_text, \ @@ -213,6 +215,17 @@ class OPCSCodeViewSet(viewsets.ModelViewSet): filterset_class = OPCSCodeFilter filterset_fields = ['code', 'id'] +class ResetPasswordView(PasswordResetView): + email_template_name = 'password_reset_email.html' + subject_template_name = 'password_reset_subject.txt' + def post(self, request, *args, **kwargs): + try: + return super().post(request, *args, **kwargs) + except SMTPException: + return HttpResponseServerError('''SMTP settings have not been configured.
+ Please visit https://medcattrainer.readthedocs.io for more information to resolve this.
+ You can also ask a question at: https://discourse.cogstack.org/c/medcat/5''') + @api_view(http_method_names=['GET']) def get_anno_tool_conf(_): diff --git a/webapp/api/core/urls.py b/webapp/api/core/urls.py index 55968447..3746f48e 100644 --- a/webapp/api/core/urls.py +++ b/webapp/api/core/urls.py @@ -70,7 +70,7 @@ path('api/concept-path/', api.views.cdb_concept_path), path('api/generate-concept-filter-json/', api.views.generate_concept_filter_flat_json), path('api/generate-concept-filter/', api.views.generate_concept_filter), - path('reset_password/', pw_views.PasswordResetView.as_view(email_template_name="password_reset_email.html", subject_template_name="password_reset_subject.txt"), name ='reset_password'), + path('reset_password/', api.views.ResetPasswordView.as_view(), name ='reset_password'), path('reset_password_sent/', pw_views.PasswordResetDoneView.as_view(), name ='password_reset_done'), path('reset//', pw_views.PasswordResetConfirmView.as_view(), name ='password_reset_confirm'), path('reset_password_complete/', pw_views.PasswordResetCompleteView.as_view(), name ='password_reset_complete'), From 468c2d3993c032fee5553fc4d84182f0d70d5905 Mon Sep 17 00:00:00 2001 From: Adam Sutton Date: Sat, 20 Jan 2024 00:35:11 +0000 Subject: [PATCH 09/11] added documentation, and env variables --- docs/installation.md | 12 ++++++++++++ envs/env | 6 ++++++ envs/env-prod | 5 +++++ webapp/api/api/views.py | 2 +- webapp/api/core/settings.py | 4 ++-- 5 files changed, 26 insertions(+), 3 deletions(-) diff --git a/docs/installation.md b/docs/installation.md index b27f4e2d..6f8f9d3f 100644 --- a/docs/installation.md +++ b/docs/installation.md @@ -40,6 +40,14 @@ On MAC: https://docs.docker.com/docker-for-mac/#memory On Windows: https://docs.docker.com/docker-for-windows/#resources +### (Optional) SMTP Setup + +For password resets and other emailing services email environment variables are required to be set up. + +Personal email accounts can be set up by users to do this, or you can contact someone in CogStack for a cogstack no email credentials. + +The environment variables required are listed in [Environment Variables.](#(optional)-environment-variables) + ### (Optional) Environment Variables Environment variables are used to configure the app: @@ -48,6 +56,10 @@ Environment variables are used to configure the app: |MEDCAT_CONFIG_FILE|MedCAT config file as described [here](https://github.com/CogStack/MedCAT/blob/master/medcat/config.py)| |BEHIND_RP| If you're running MedCATtrainer, use 1, otherwise this defaults to 0 i.e. False| |MCTRAINER_PORT|The port to run the trainer app on| +|EMAIL_USER|Email address which will be used to send users emails regarding password resets| +|EMAIL_PASS|The password or authentication key which will be used with the email address| +|EMAIL_HOST|The hostname of the SMTP server which will be used to send email (default: mail.cogstack.org)| +|EMAIL_PORT|The port that the SMTP server is listening to, common numbers are 25, 465, 587 (default: 465)| Set these and re-run the docker-compose file. diff --git a/envs/env b/envs/env index 1b3aa62f..202b4aac 100644 --- a/envs/env +++ b/envs/env @@ -33,3 +33,9 @@ RESUBMIT_ALL_ON_STARTUP=1 # Front end env vars LOAD_NUM_DOC_PAGES=10 + +# SMTP EMAIL SETTINGS +EMAIL_USER=example@example.com +EMAIL_PASS=tobechanged +EMAIL_HOST=mail.cogstack.org +EMAIL_PORT=465 \ No newline at end of file diff --git a/envs/env-prod b/envs/env-prod index 0026437c..baf3ce6c 100644 --- a/envs/env-prod +++ b/envs/env-prod @@ -35,3 +35,8 @@ RESUBMIT_ALL_ON_STARTUP=1 # Front end env vars LOAD_NUM_DOC_PAGES=10 +# SMTP EMAIL SETTINGS +EMAIL_USER=example@example.com +EMAIL_PASS=tobechanged +EMAIL_HOST=mail.cogstack.org +EMAIL_PORT=465 \ No newline at end of file diff --git a/webapp/api/api/views.py b/webapp/api/api/views.py index 3afca0e6..0cadeaa3 100644 --- a/webapp/api/api/views.py +++ b/webapp/api/api/views.py @@ -222,7 +222,7 @@ def post(self, request, *args, **kwargs): try: return super().post(request, *args, **kwargs) except SMTPException: - return HttpResponseServerError('''SMTP settings have not been configured.
+ return HttpResponseServerError('''SMTP settings are not configured correctly.
Please visit https://medcattrainer.readthedocs.io for more information to resolve this.
You can also ask a question at: https://discourse.cogstack.org/c/medcat/5''') diff --git a/webapp/api/core/settings.py b/webapp/api/core/settings.py index 29b4789b..ce3de7a1 100644 --- a/webapp/api/core/settings.py +++ b/webapp/api/core/settings.py @@ -198,8 +198,8 @@ # EMAIL_BACKEND = "django.core.mail.backends.console.EmailBackend" EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend' -EMAIL_HOST = 'smtp.gmail.com' -EMAIL_PORT = 587 +EMAIL_HOST = os.environ.get('EMAIL_HOST') +EMAIL_PORT = os.environ.get('EMAIL_PORT') EMAIL_HOST_USER = os.environ.get('EMAIL_USER') EMAIL_HOST_PASSWORD = os.environ.get('EMAIL_PASS') EMAIL_USE_TLS = True \ No newline at end of file From bb44883b532e33f1db093907d2fecfde7f9163db Mon Sep 17 00:00:00 2001 From: adam-sutton-1992 Date: Mon, 22 Jan 2024 23:40:14 +0000 Subject: [PATCH 10/11] forgotten password visible with email settings set --- envs/env | 6 +++--- envs/env-prod | 4 ++-- webapp/frontend/.env | 1 + webapp/frontend/src/components/common/Login.vue | 5 +++-- webapp/frontend/vite.config.js | 10 ++++++++-- 5 files changed, 17 insertions(+), 9 deletions(-) create mode 100644 webapp/frontend/.env diff --git a/envs/env b/envs/env index 202b4aac..404f8884 100644 --- a/envs/env +++ b/envs/env @@ -34,8 +34,8 @@ RESUBMIT_ALL_ON_STARTUP=1 # Front end env vars LOAD_NUM_DOC_PAGES=10 -# SMTP EMAIL SETTINGS -EMAIL_USER=example@example.com -EMAIL_PASS=tobechanged +# SMTP email settings - when settings are configured go to webapp/frontend/.env and set VITE_APP_EMAIL to 1 +EMAIL_USER=example@cogstack.org +EMAIL_PASS="to be changed" EMAIL_HOST=mail.cogstack.org EMAIL_PORT=465 \ No newline at end of file diff --git a/envs/env-prod b/envs/env-prod index baf3ce6c..19d6460b 100644 --- a/envs/env-prod +++ b/envs/env-prod @@ -36,7 +36,7 @@ RESUBMIT_ALL_ON_STARTUP=1 LOAD_NUM_DOC_PAGES=10 # SMTP EMAIL SETTINGS -EMAIL_USER=example@example.com -EMAIL_PASS=tobechanged +EMAIL_USER=example@cogstack.org +EMAIL_PASS="to be changed" EMAIL_HOST=mail.cogstack.org EMAIL_PORT=465 \ No newline at end of file diff --git a/webapp/frontend/.env b/webapp/frontend/.env new file mode 100644 index 00000000..6ed2c18c --- /dev/null +++ b/webapp/frontend/.env @@ -0,0 +1 @@ +VITE_APP_EMAIL=0 # Set to 1 when email settings are correctly configured \ No newline at end of file diff --git a/webapp/frontend/src/components/common/Login.vue b/webapp/frontend/src/components/common/Login.vue index c1a41da6..c9486bec 100644 --- a/webapp/frontend/src/components/common/Login.vue +++ b/webapp/frontend/src/components/common/Login.vue @@ -7,7 +7,7 @@ - Forgotten Password + Forgotten Password Username and/or password incorrect Cannot determine admin status of username @@ -41,7 +41,8 @@ export default { uname: '', password: '', failed: false, - failedAdminStatusCheck: false + failedAdminStatusCheck: false, + reset_pw: import.meta.env.VITE_APP_EMAIL === '1', } }, methods: { diff --git a/webapp/frontend/vite.config.js b/webapp/frontend/vite.config.js index 24385af2..e4aef709 100644 --- a/webapp/frontend/vite.config.js +++ b/webapp/frontend/vite.config.js @@ -1,9 +1,14 @@ import { createVuePlugin as vue } from "vite-plugin-vue2"; -import { defineConfig } from 'vite' +import { defineConfig, loadEnv } from 'vite' // https://vitejs.dev/config/ const path = require("path"); -export default defineConfig({ +export default defineConfig(({ mode }) => { + const env = loadEnv(mode, process.cwd(), '') + return { + define: { + __APP_ENV__: JSON.stringify(env.APP_ENV), + }, plugins: [vue()], resolve: { alias: { @@ -39,4 +44,5 @@ export default defineConfig({ } } } +} }) From da55c5334baae1098efcb9fad33e432b6e2222f6 Mon Sep 17 00:00:00 2001 From: adam-sutton-1992 Date: Mon, 22 Jan 2024 23:59:18 +0000 Subject: [PATCH 11/11] added info about environment vars --- docs/installation.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/installation.md b/docs/installation.md index 6f8f9d3f..df14a752 100644 --- a/docs/installation.md +++ b/docs/installation.md @@ -48,6 +48,8 @@ Personal email accounts can be set up by users to do this, or you can contact so The environment variables required are listed in [Environment Variables.](#(optional)-environment-variables) +Environment Variables are located in envs/env or envs/env-prod, when those are set webapp/frontend/.env must change "VITE_APP_EMAIL" to 1. + ### (Optional) Environment Variables Environment variables are used to configure the app: