mirror of
				https://github.com/encode/django-rest-framework.git
				synced 2025-11-04 01:47:59 +03:00 
			
		
		
		
	Fix 403 for POST and PUT from the UI with UserLoggedInAuthentication
This commit is contained in:
		
							parent
							
								
									e712ab0ba1
								
							
						
					
					
						commit
						0e085364fd
					
				| 
						 | 
				
			
			@ -96,11 +96,16 @@ class UserLoggedInAuthentication(BaseAuthentication):
 | 
			
		|||
            # Temporarily replace request.POST with .DATA, to use our generic parsing.
 | 
			
		||||
            # If DATA is not dict-like, use an empty dict.
 | 
			
		||||
            if request.method.upper() == 'POST':
 | 
			
		||||
                token = request.POST.get('csrfmiddlewaretoken')
 | 
			
		||||
 | 
			
		||||
                if hasattr(self.view.DATA, 'get'):
 | 
			
		||||
                    request._post = self.view.DATA
 | 
			
		||||
                    request._post = self.view.DATA.copy()
 | 
			
		||||
                else:
 | 
			
		||||
                    request._post = {}
 | 
			
		||||
 | 
			
		||||
                if token is not None:
 | 
			
		||||
                    request._post['csrfmiddlewaretoken'] = token
 | 
			
		||||
 | 
			
		||||
            resp = CsrfViewMiddleware().process_view(request, None, (), {})
 | 
			
		||||
 | 
			
		||||
            # Replace request.POST
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue
	
	Block a user