mirror of
				https://github.com/inventree/InvenTree.git
				synced 2025-11-04 15:15:42 +00:00 
			
		
		
		
	fix login middleware
This commit is contained in:
		@@ -111,7 +111,6 @@ class AuthRequiredMiddleware:
 | 
				
			|||||||
                # List of URL endpoints we *do not* want to redirect to
 | 
					                # List of URL endpoints we *do not* want to redirect to
 | 
				
			||||||
                urls = [
 | 
					                urls = [
 | 
				
			||||||
                    reverse_lazy('account_login'),
 | 
					                    reverse_lazy('account_login'),
 | 
				
			||||||
                    reverse_lazy('account_logout'),
 | 
					 | 
				
			||||||
                    reverse_lazy('admin:login'),
 | 
					                    reverse_lazy('admin:login'),
 | 
				
			||||||
                    reverse_lazy('admin:logout'),
 | 
					                    reverse_lazy('admin:logout'),
 | 
				
			||||||
                ]
 | 
					                ]
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -32,16 +32,9 @@ class MiddlewareTests(InvenTreeTestCase):
 | 
				
			|||||||
        # logout
 | 
					        # logout
 | 
				
			||||||
        self.client.logout()
 | 
					        self.client.logout()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        # check that static files go through
 | 
					 | 
				
			||||||
        # TODO @matmair re-enable this check
 | 
					 | 
				
			||||||
        # self.check_path('/static/css/inventree.css', 302)
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        # check that account things go through
 | 
					        # check that account things go through
 | 
				
			||||||
        self.check_path(reverse('account_login'))
 | 
					        self.check_path(reverse('account_login'))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        # logout goes directly to login
 | 
					 | 
				
			||||||
        self.check_path(reverse('account_logout'))
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        # check that frontend code is redirected to login
 | 
					        # check that frontend code is redirected to login
 | 
				
			||||||
        response = self.check_path(reverse('stats'), 302)
 | 
					        response = self.check_path(reverse('stats'), 302)
 | 
				
			||||||
        self.assertEqual(response.url, '/accounts/login/?next=/stats/')
 | 
					        self.assertEqual(response.url, '/accounts/login/?next=/stats/')
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -203,7 +203,7 @@ frontendpatterns = [
 | 
				
			|||||||
    # Add a redirect for login views
 | 
					    # Add a redirect for login views
 | 
				
			||||||
    path(
 | 
					    path(
 | 
				
			||||||
        'accounts/login/',
 | 
					        'accounts/login/',
 | 
				
			||||||
        RedirectView.as_view(url=settings.FRONTEND_URL_BASE, permanent=False),
 | 
					        RedirectView.as_view(url=f'/{settings.FRONTEND_URL_BASE}', permanent=False),
 | 
				
			||||||
        name='account_login',
 | 
					        name='account_login',
 | 
				
			||||||
    ),
 | 
					    ),
 | 
				
			||||||
]
 | 
					]
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user