From 9fff753b2b5590400dc8cb2127dffb7588732109 Mon Sep 17 00:00:00 2001 From: Garth Johnson Date: Mon, 16 Dec 2024 07:44:39 +0000 Subject: [PATCH 1/4] userena --- .gitignore | 1 + accounts/__init__.py | 0 accounts/admin.py | 3 +++ accounts/apps.py | 6 ++++++ accounts/migrations/0001_initial.py | 33 +++++++++++++++++++++++++++++ accounts/migrations/__init__.py | 0 accounts/models.py | 13 ++++++++++++ accounts/tests.py | 3 +++ accounts/views.py | 3 +++ backend/settings.py | 28 ++++++++++++++++++++++++ backend/urls.py | 3 ++- requirements.txt | 3 +++ 12 files changed, 95 insertions(+), 1 deletion(-) create mode 100644 accounts/__init__.py create mode 100644 accounts/admin.py create mode 100644 accounts/apps.py create mode 100644 accounts/migrations/0001_initial.py create mode 100644 accounts/migrations/__init__.py create mode 100644 accounts/models.py create mode 100644 accounts/tests.py create mode 100644 accounts/views.py diff --git a/.gitignore b/.gitignore index 7ffeb8f..88b071d 100644 --- a/.gitignore +++ b/.gitignore @@ -163,3 +163,4 @@ cython_debug/ .env /staticfiles_collected/ +/data/ \ No newline at end of file diff --git a/accounts/__init__.py b/accounts/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/accounts/admin.py b/accounts/admin.py new file mode 100644 index 0000000..8c38f3f --- /dev/null +++ b/accounts/admin.py @@ -0,0 +1,3 @@ +from django.contrib import admin + +# Register your models here. diff --git a/accounts/apps.py b/accounts/apps.py new file mode 100644 index 0000000..3e3c765 --- /dev/null +++ b/accounts/apps.py @@ -0,0 +1,6 @@ +from django.apps import AppConfig + + +class AccountsConfig(AppConfig): + default_auto_field = 'django.db.models.BigAutoField' + name = 'accounts' diff --git a/accounts/migrations/0001_initial.py b/accounts/migrations/0001_initial.py new file mode 100644 index 0000000..322d10b --- /dev/null +++ b/accounts/migrations/0001_initial.py @@ -0,0 +1,33 @@ +# Generated by Django 5.1.3 on 2024-12-16 03:49 + +import django.db.models.deletion +import easy_thumbnails.fields +import userena.models +from django.conf import settings +from django.db import migrations, models + + +class Migration(migrations.Migration): + + initial = True + + dependencies = [ + migrations.swappable_dependency(settings.AUTH_USER_MODEL), + ] + + operations = [ + migrations.CreateModel( + name='UserProfile', + fields=[ + ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('mugshot', easy_thumbnails.fields.ThumbnailerImageField(blank=True, help_text='A personal image displayed in your profile.', upload_to=userena.models.upload_to_mugshot, verbose_name='mugshot')), + ('privacy', models.CharField(choices=[('open', 'Open'), ('registered', 'Registered'), ('closed', 'Closed')], default='registered', help_text='Designates who can view your profile.', max_length=15, verbose_name='privacy')), + ('user', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, related_name='my_profile', to=settings.AUTH_USER_MODEL, verbose_name='user')), + ], + options={ + 'permissions': (('view_profile', 'Can view profile'),), + 'abstract': False, + 'default_permissions': ('add', 'change', 'delete'), + }, + ), + ] diff --git a/accounts/migrations/__init__.py b/accounts/migrations/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/accounts/models.py b/accounts/models.py new file mode 100644 index 0000000..693dac9 --- /dev/null +++ b/accounts/models.py @@ -0,0 +1,13 @@ +from django.db import models + +# Create your models here. +from django.contrib.auth.models import User +from django.utils.translation import gettext as _ +from userena.models import UserenaBaseProfile + +class UserProfile(UserenaBaseProfile): + user = models.OneToOneField(User, + unique=True, + verbose_name=_('user'), + related_name='my_profile', + on_delete=models.CASCADE) \ No newline at end of file diff --git a/accounts/tests.py b/accounts/tests.py new file mode 100644 index 0000000..7ce503c --- /dev/null +++ b/accounts/tests.py @@ -0,0 +1,3 @@ +from django.test import TestCase + +# Create your tests here. diff --git a/accounts/views.py b/accounts/views.py new file mode 100644 index 0000000..91ea44a --- /dev/null +++ b/accounts/views.py @@ -0,0 +1,3 @@ +from django.shortcuts import render + +# Create your views here. diff --git a/backend/settings.py b/backend/settings.py index 46cd7ec..dbf0fca 100644 --- a/backend/settings.py +++ b/backend/settings.py @@ -84,6 +84,12 @@ # Django Debug Toolbar 'debug_toolbar', + + # User accounts/profiles + 'accounts', + 'userena', + 'guardian', + ] MIDDLEWARE = [ @@ -246,3 +252,25 @@ '0.0.0.0', # For Docker on Windows and macOS 'localhost', # For Docker on Windows and macOS ] + +AUTHENTICATION_BACKENDS = ( + 'userena.backends.UserenaAuthenticationBackend', + 'guardian.backends.ObjectPermissionBackend', + 'django.contrib.auth.backends.ModelBackend', +) +EMAIL_BACKEND = 'django.core.mail.backends.dummy.EmailBackend' +EMAIL_USE_TLS = True +EMAIL_HOST = 'smtp.gmail.com' +EMAIL_PORT = 587 +EMAIL_HOST_USER = 'yourgmailaccount@gmail.com' +EMAIL_HOST_PASSWORD = 'yourgmailpassword' +DEFAULT_FROM_EMAIL = EMAIL_HOST_USER +SERVER_EMAIL = EMAIL_HOST_USER + +ANONYMOUS_USER_NAME = 'AnonymousUser' + +AUTH_PROFILE_MODULE = 'accounts.UserProfile' + +USERENA_SIGNIN_REDIRECT_URL = '/' +LOGIN_URL = '/accounts/signin/' +LOGOUT_URL = '/accounts/signout/' \ No newline at end of file diff --git a/backend/urls.py b/backend/urls.py index 7e20624..c4439b3 100644 --- a/backend/urls.py +++ b/backend/urls.py @@ -6,7 +6,8 @@ urlpatterns = [ path('admin/', admin.site.urls), - path("material/", include('theme_material_kit.urls')), + path('material/', include('theme_material_kit.urls')), + path('accounts/', include('userena.urls')), ] + debug_toolbar_urls() if settings.DEBUG: diff --git a/requirements.txt b/requirements.txt index 1f83cce..c85df79 100644 --- a/requirements.txt +++ b/requirements.txt @@ -175,4 +175,7 @@ str2bool==1.1 # UI django-theme-material-kit==1.0.25 +# Profiles +django-userena-ce==7.0.3 + django-debug-toolbar \ No newline at end of file From fb68b508908b9ff554abc4d4adc1bad1bda86b66 Mon Sep 17 00:00:00 2001 From: Garth Johnson Date: Thu, 19 Dec 2024 09:20:23 +0000 Subject: [PATCH 2/4] fixing vuln --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index c85df79..9325bc1 100644 --- a/requirements.txt +++ b/requirements.txt @@ -22,7 +22,7 @@ cssselect2==0.7.0 # via svglib dj-database-url==2.3.0 # via -r requirements.in -django==5.1.3 +django==5.1.4 # via # -r requirements.in # dj-database-url From f0598042c17cdf4c2ffac750fb6233c2d735a5e4 Mon Sep 17 00:00:00 2001 From: Garth Johnson Date: Fri, 20 Dec 2024 08:50:56 +0000 Subject: [PATCH 3/4] removed userena --- backend/settings.py | 31 +++++++++++++------------------ backend/urls.py | 1 - requirements.txt | 3 +-- 3 files changed, 14 insertions(+), 21 deletions(-) diff --git a/backend/settings.py b/backend/settings.py index c6fed62..98cd19b 100644 --- a/backend/settings.py +++ b/backend/settings.py @@ -87,7 +87,6 @@ # User accounts/profiles 'accounts', - 'userena', 'guardian', ] @@ -254,26 +253,22 @@ ] AUTHENTICATION_BACKENDS = ( - 'userena.backends.UserenaAuthenticationBackend', 'guardian.backends.ObjectPermissionBackend', 'django.contrib.auth.backends.ModelBackend', ) -EMAIL_BACKEND = 'django.core.mail.backends.dummy.EmailBackend' -EMAIL_USE_TLS = True -EMAIL_HOST = 'smtp.gmail.com' -EMAIL_PORT = 587 -EMAIL_HOST_USER = 'yourgmailaccount@gmail.com' -EMAIL_HOST_PASSWORD = 'yourgmailpassword' -DEFAULT_FROM_EMAIL = EMAIL_HOST_USER -SERVER_EMAIL = EMAIL_HOST_USER - -ANONYMOUS_USER_NAME = 'AnonymousUser' - -AUTH_PROFILE_MODULE = 'accounts.UserProfile' - -USERENA_SIGNIN_REDIRECT_URL = '/' -LOGIN_URL = '/accounts/signin/' -LOGOUT_URL = '/accounts/signout/' +#EMAIL_BACKEND = 'django.core.mail.backends.dummy.EmailBackend' +#EMAIL_USE_TLS = True +#EMAIL_HOST = 'smtp.gmail.com' +#EMAIL_PORT = 587 +#EMAIL_HOST_USER = 'yourgmailaccount@gmail.com' +#EMAIL_HOST_PASSWORD = 'yourgmailpassword' +#DEFAULT_FROM_EMAIL = EMAIL_HOST_USER +#SERVER_EMAIL = EMAIL_HOST_USER + +#AUTH_PROFILE_MODULE = 'accounts.UserProfile' + + +# Django Debug Toolbar fix for use inside a container DEBUG_TOOLBAR_CONFIG = { 'SHOW_TOOLBAR_CALLBACK': lambda _request: DEBUG } \ No newline at end of file diff --git a/backend/urls.py b/backend/urls.py index c4439b3..c88ea29 100644 --- a/backend/urls.py +++ b/backend/urls.py @@ -7,7 +7,6 @@ urlpatterns = [ path('admin/', admin.site.urls), path('material/', include('theme_material_kit.urls')), - path('accounts/', include('userena.urls')), ] + debug_toolbar_urls() if settings.DEBUG: diff --git a/requirements.txt b/requirements.txt index 9325bc1..404cd0f 100644 --- a/requirements.txt +++ b/requirements.txt @@ -175,7 +175,6 @@ str2bool==1.1 # UI django-theme-material-kit==1.0.25 -# Profiles -django-userena-ce==7.0.3 + django-debug-toolbar \ No newline at end of file From a1834910f57d3ccf7acc9904392e21af6483cd82 Mon Sep 17 00:00:00 2001 From: Garth Johnson Date: Fri, 20 Dec 2024 09:10:37 +0000 Subject: [PATCH 4/4] removed broken userena components --- accounts/__init__.py | 0 accounts/admin.py | 3 --- accounts/apps.py | 6 ------ accounts/migrations/0001_initial.py | 33 ----------------------------- accounts/migrations/__init__.py | 0 accounts/models.py | 13 ------------ accounts/tests.py | 3 --- accounts/views.py | 3 --- backend/settings.py | 1 - requirements.txt | 2 +- 10 files changed, 1 insertion(+), 63 deletions(-) delete mode 100644 accounts/__init__.py delete mode 100644 accounts/admin.py delete mode 100644 accounts/apps.py delete mode 100644 accounts/migrations/0001_initial.py delete mode 100644 accounts/migrations/__init__.py delete mode 100644 accounts/models.py delete mode 100644 accounts/tests.py delete mode 100644 accounts/views.py diff --git a/accounts/__init__.py b/accounts/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/accounts/admin.py b/accounts/admin.py deleted file mode 100644 index 8c38f3f..0000000 --- a/accounts/admin.py +++ /dev/null @@ -1,3 +0,0 @@ -from django.contrib import admin - -# Register your models here. diff --git a/accounts/apps.py b/accounts/apps.py deleted file mode 100644 index 3e3c765..0000000 --- a/accounts/apps.py +++ /dev/null @@ -1,6 +0,0 @@ -from django.apps import AppConfig - - -class AccountsConfig(AppConfig): - default_auto_field = 'django.db.models.BigAutoField' - name = 'accounts' diff --git a/accounts/migrations/0001_initial.py b/accounts/migrations/0001_initial.py deleted file mode 100644 index 322d10b..0000000 --- a/accounts/migrations/0001_initial.py +++ /dev/null @@ -1,33 +0,0 @@ -# Generated by Django 5.1.3 on 2024-12-16 03:49 - -import django.db.models.deletion -import easy_thumbnails.fields -import userena.models -from django.conf import settings -from django.db import migrations, models - - -class Migration(migrations.Migration): - - initial = True - - dependencies = [ - migrations.swappable_dependency(settings.AUTH_USER_MODEL), - ] - - operations = [ - migrations.CreateModel( - name='UserProfile', - fields=[ - ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('mugshot', easy_thumbnails.fields.ThumbnailerImageField(blank=True, help_text='A personal image displayed in your profile.', upload_to=userena.models.upload_to_mugshot, verbose_name='mugshot')), - ('privacy', models.CharField(choices=[('open', 'Open'), ('registered', 'Registered'), ('closed', 'Closed')], default='registered', help_text='Designates who can view your profile.', max_length=15, verbose_name='privacy')), - ('user', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, related_name='my_profile', to=settings.AUTH_USER_MODEL, verbose_name='user')), - ], - options={ - 'permissions': (('view_profile', 'Can view profile'),), - 'abstract': False, - 'default_permissions': ('add', 'change', 'delete'), - }, - ), - ] diff --git a/accounts/migrations/__init__.py b/accounts/migrations/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/accounts/models.py b/accounts/models.py deleted file mode 100644 index 693dac9..0000000 --- a/accounts/models.py +++ /dev/null @@ -1,13 +0,0 @@ -from django.db import models - -# Create your models here. -from django.contrib.auth.models import User -from django.utils.translation import gettext as _ -from userena.models import UserenaBaseProfile - -class UserProfile(UserenaBaseProfile): - user = models.OneToOneField(User, - unique=True, - verbose_name=_('user'), - related_name='my_profile', - on_delete=models.CASCADE) \ No newline at end of file diff --git a/accounts/tests.py b/accounts/tests.py deleted file mode 100644 index 7ce503c..0000000 --- a/accounts/tests.py +++ /dev/null @@ -1,3 +0,0 @@ -from django.test import TestCase - -# Create your tests here. diff --git a/accounts/views.py b/accounts/views.py deleted file mode 100644 index 91ea44a..0000000 --- a/accounts/views.py +++ /dev/null @@ -1,3 +0,0 @@ -from django.shortcuts import render - -# Create your views here. diff --git a/backend/settings.py b/backend/settings.py index 98cd19b..9912c9f 100644 --- a/backend/settings.py +++ b/backend/settings.py @@ -86,7 +86,6 @@ 'debug_toolbar', # User accounts/profiles - 'accounts', 'guardian', ] diff --git a/requirements.txt b/requirements.txt index 404cd0f..bf55300 100644 --- a/requirements.txt +++ b/requirements.txt @@ -176,5 +176,5 @@ str2bool==1.1 django-theme-material-kit==1.0.25 - +guardian==0.2.2 django-debug-toolbar \ No newline at end of file