mirror of
https://github.com/inventree/InvenTree.git
synced 2025-06-17 20:45:44 +00:00
respect more settings
This commit is contained in:
@ -3,6 +3,7 @@
|
|||||||
from django import forms
|
from django import forms
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.contrib.auth.models import Group
|
from django.contrib.auth.models import Group
|
||||||
|
from django.core.exceptions import PermissionDenied
|
||||||
from django.http import HttpRequest, HttpResponseRedirect
|
from django.http import HttpRequest, HttpResponseRedirect
|
||||||
from django.urls import reverse
|
from django.urls import reverse
|
||||||
from django.utils.translation import gettext_lazy as _
|
from django.utils.translation import gettext_lazy as _
|
||||||
@ -185,6 +186,12 @@ class CustomAccountAdapter(RegistrationMixin, DefaultAccountAdapter):
|
|||||||
url = InvenTree.helpers_model.construct_absolute_url(url)
|
url = InvenTree.helpers_model.construct_absolute_url(url)
|
||||||
return url
|
return url
|
||||||
|
|
||||||
|
def send_password_reset_mail(self, user, email, context):
|
||||||
|
"""Send the password reset mail."""
|
||||||
|
if not get_global_setting('LOGIN_ENABLE_PWD_FORGOT'):
|
||||||
|
raise PermissionDenied('Password reset is disabled')
|
||||||
|
return super().send_password_reset_mail(self, user, email, context)
|
||||||
|
|
||||||
|
|
||||||
class CustomSocialAccountAdapter(RegistrationMixin, DefaultSocialAccountAdapter):
|
class CustomSocialAccountAdapter(RegistrationMixin, DefaultSocialAccountAdapter):
|
||||||
"""Override of adapter to use dynamic settings."""
|
"""Override of adapter to use dynamic settings."""
|
||||||
@ -211,6 +218,10 @@ class CustomSocialAccountAdapter(RegistrationMixin, DefaultSocialAccountAdapter)
|
|||||||
log_error(path, error_name=error, error_data=exception)
|
log_error(path, error_name=error, error_data=exception)
|
||||||
logger.error("SSO error for provider '%s' - check admin error log", provider_id)
|
logger.error("SSO error for provider '%s' - check admin error log", provider_id)
|
||||||
|
|
||||||
|
def get_connect_redirect_url(self, request, socialaccount):
|
||||||
|
"""Redirect to the frontend after connecting an account."""
|
||||||
|
return request.build_absolute_uri(f'/{settings.FRONTEND_URL_BASE}/')
|
||||||
|
|
||||||
|
|
||||||
class CustomMFAAdapter(DefaultMFAAdapter):
|
class CustomMFAAdapter(DefaultMFAAdapter):
|
||||||
"""Override of adapter to use dynamic settings."""
|
"""Override of adapter to use dynamic settings."""
|
||||||
|
Reference in New Issue
Block a user