Coverage for src/backend/InvenTree/InvenTree/views.py: 29%

5 statements  

« prev     ^ index     » next       coverage.py v7.15.2, created at 2026-10-07 17:47 +0000

1"""Various Views which provide extra functionality over base Django Views. 

2 

3In particular these views provide base functionality for rendering Django forms 

4as JSON objects and passing them to modal forms (using jQuery / bootstrap). 

5""" 

6 

7from django.http import HttpResponse 

8 

9 

10def auth_request(request): 

11 """Simple 'auth' endpoint used to determine if the user is authenticated. 

12 

13 Useful for (for example) redirecting authentication requests through django's permission framework. 

14 """ 

15 if ( 

16 not request.user 

17 or not request.user.is_authenticated 

18 or not request.user.is_active 

19 ): 

20 # This is very unlikely to be reached, as the middleware stack should intercept unauthenticated requests 

21 return HttpResponse(status=403) # pragma: no cover 

22 

23 # User is authenticated and active 

24 return HttpResponse(status=200)