Skip to content

Commit

Permalink
backport email fix (#5409)
Browse files Browse the repository at this point in the history
- Backport of #5396
  • Loading branch information
SchrodingersGat authored Aug 8, 2023
1 parent f526dcd commit 57eada1
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 11 deletions.
9 changes: 9 additions & 0 deletions InvenTree/InvenTree/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,15 @@ def send_mail(self, template_prefix, email, context):

return False

def get_email_confirmation_url(self, request, emailconfirmation):
"""Construct the email confirmation url"""

from InvenTree.helpers_model import construct_absolute_url

url = super().get_email_confirmation_url(request, emailconfirmation)
url = construct_absolute_url(url)
return url


class CustomSocialAccountAdapter(CustomUrlMixin, RegistratonMixin, DefaultSocialAccountAdapter):
"""Override of adapter to use dynamic settings."""
Expand Down
4 changes: 1 addition & 3 deletions InvenTree/InvenTree/helpers_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,7 @@ def construct_absolute_url(*arg, **kwargs):
# Otherwise, try to use the InvenTree setting
try:
site_url = common.models.InvenTreeSetting.get_setting('INVENTREE_BASE_URL', create=False, cache=False)
except ProgrammingError:
pass
except OperationalError:
except (ProgrammingError, OperationalError):
pass

if not site_url:
Expand Down
2 changes: 2 additions & 0 deletions InvenTree/InvenTree/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -601,6 +601,8 @@
REMOTE_LOGIN = get_boolean_setting('INVENTREE_REMOTE_LOGIN', 'remote_login_enabled', False)
REMOTE_LOGIN_HEADER = get_setting('INVENTREE_REMOTE_LOGIN_HEADER', 'remote_login_header', 'REMOTE_USER')

LOGIN_REDIRECT_URL = "/index/"

# sentry.io integration for error reporting
SENTRY_ENABLED = get_boolean_setting('INVENTREE_SENTRY_ENABLED', 'sentry_enabled', False)

Expand Down
20 changes: 12 additions & 8 deletions InvenTree/InvenTree/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
from django.urls import include, path, re_path
from django.views.generic.base import RedirectView

from dj_rest_auth.registration.views import (SocialAccountDisconnectView,
from dj_rest_auth.registration.views import (ConfirmEmailView,
SocialAccountDisconnectView,
SocialAccountListView)
from drf_spectacular.views import SpectacularAPIView, SpectacularRedocView

Expand Down Expand Up @@ -74,13 +75,16 @@
# InvenTree information endpoint
path('', InfoView.as_view(), name='api-inventree-info'),

# Third party API endpoints
path('auth/', include('dj_rest_auth.urls')),
path('auth/registration/', include('dj_rest_auth.registration.urls')),
path('auth/providers/', SocialProvierListView.as_view(), name='social_providers'),
path('auth/social/', include(social_auth_urlpatterns)),
path('auth/social/', SocialAccountListView.as_view(), name='social_account_list'),
path('auth/social/<int:pk>/disconnect/', SocialAccountDisconnectView.as_view(), name='social_account_disconnect'),
# Auth API endpoints
path('auth/', include([
re_path(r'^registration/account-confirm-email/(?P<key>[-:\w]+)/$', ConfirmEmailView.as_view(), name='account_confirm_email'),
path('registration/', include('dj_rest_auth.registration.urls')),
path('providers/', SocialProvierListView.as_view(), name='social_providers'),
path('social/', include(social_auth_urlpatterns)),
path('social/', SocialAccountListView.as_view(), name='social_account_list'),
path('social/<int:pk>/disconnect/', SocialAccountDisconnectView.as_view(), name='social_account_disconnect'),
path('', include('dj_rest_auth.urls')),
])),

# Unknown endpoint
re_path(r'^.*$', NotFoundView.as_view(), name='api-404'),
Expand Down

0 comments on commit 57eada1

Please sign in to comment.