Correct recursion loop in authentication
authorymh <ymh.work@gmail.com>
Mon, 25 Jul 2016 15:53:32 +0200
changeset 94 f3fa1e9d0b24
parent 93 c895dbf60086
child 95 c8c95c522f48
Correct recursion loop in authentication
server/src/metaeducation/auth.py
--- a/server/src/metaeducation/auth.py	Mon Jul 25 14:15:12 2016 +0200
+++ b/server/src/metaeducation/auth.py	Mon Jul 25 15:53:32 2016 +0200
@@ -91,7 +91,7 @@
         logger.debug("CLIENT CREDENTIAL AUTH: user %r is authenticated by token %r, auth success", external_id, token)
 
 
-        if hasattr(request, 'renkan_request_id') and user != getattr(request,'user', None):
+        if hasattr(request, 'renkan_request_id'): # ideally should check if new user is different, but that cause a recursion loop in rest famework (c.f. : rest_framework/request.py", line 193, in user : self._authenticate())) - user != getattr(request,'user', None):
             # Re-register the tracking handlers with the new user
             logger.debug("CLIENT CREDENTIAL AUTH: Change the registered tracking handlers to user %r", user.external_id)
             change_handlers_user(user, request.renkan_request_id)