mirror of
https://github.com/netbox-community/netbox.git
synced 2025-09-06 14:23:36 -06:00
Update media view to preserve the exception.
This commit is contained in:
parent
1cb10eeb4f
commit
244e738ebb
@ -6,7 +6,6 @@ from django.core.exceptions import ImproperlyConfigured
|
||||
from django.urls import reverse
|
||||
from django.urls.exceptions import NoReverseMatch
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
from rest_framework.exceptions import AuthenticationFailed
|
||||
|
||||
from netbox.api.authentication import TokenAuthentication
|
||||
from netbox.plugins import PluginConfig
|
||||
@ -47,12 +46,9 @@ class TokenConditionalLoginRequiredMixin(ConditionalLoginRequiredMixin):
|
||||
# Attempt to authenticate the user using a DRF token, if provided
|
||||
if settings.LOGIN_REQUIRED and not request.user.is_authenticated:
|
||||
authenticator = TokenAuthentication()
|
||||
try:
|
||||
auth_info = authenticator.authenticate(request)
|
||||
if auth_info is not None:
|
||||
request.user = auth_info[0] # User object
|
||||
except AuthenticationFailed:
|
||||
pass
|
||||
|
||||
return super().dispatch(request, *args, **kwargs)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user