1
0
mirror of https://github.com/ansible/awx.git synced 2024-10-31 23:51:09 +03:00

is_anonymous and is_authenticated no longer support being called as methods

This commit is contained in:
Jeff Bradberry 2019-06-13 14:13:09 -04:00
parent a6edc46cc3
commit e0693d3746
5 changed files with 5 additions and 5 deletions

View File

@ -95,7 +95,7 @@ class ModelAccessPermission(permissions.BasePermission):
''' '''
# Don't allow anonymous users. 401, not 403, hence no raised exception. # Don't allow anonymous users. 401, not 403, hence no raised exception.
if not request.user or request.user.is_anonymous(): if not request.user or request.user.is_anonymous:
return False return False
# Always allow superusers # Always allow superusers

View File

@ -24,7 +24,7 @@ def ws_connect(message):
headers = dict(message.content.get('headers', '')) headers = dict(message.content.get('headers', ''))
message.reply_channel.send({"accept": True}) message.reply_channel.send({"accept": True})
message.content['method'] = 'FAKE' message.content['method'] = 'FAKE'
if message.user.is_authenticated(): if message.user.is_authenticated:
message.reply_channel.send( message.reply_channel.send(
{"text": json.dumps({"accept": True, "user": message.user.id})} {"text": json.dumps({"accept": True, "user": message.user.id})}
) )

View File

@ -73,7 +73,7 @@ class ActivityStreamMiddleware(threading.local, MiddlewareMixin):
super().__init__(get_response) super().__init__(get_response)
def process_request(self, request): def process_request(self, request):
if hasattr(request, 'user') and hasattr(request.user, 'is_authenticated') and request.user.is_authenticated(): if hasattr(request, 'user') and request.user.is_authenticated:
user = request.user user = request.user
else: else:
user = None user = None

View File

@ -39,7 +39,7 @@ class SocialAuthMiddleware(SocialAuthExceptionMiddleware):
request.successful_authenticator = None request.successful_authenticator = None
if not request.path.startswith('/sso/') and 'migrations_notran' not in request.path: if not request.path.startswith('/sso/') and 'migrations_notran' not in request.path:
if request.user and request.user.is_authenticated(): if request.user and request.user.is_authenticated:
# The rest of the code base rely hevily on type/inheritance checks, # The rest of the code base rely hevily on type/inheritance checks,
# LazyObject sent from Django auth middleware can be buggy if not # LazyObject sent from Django auth middleware can be buggy if not
# converted back to its original object. # converted back to its original object.

View File

@ -40,7 +40,7 @@ class CompleteView(BaseRedirectView):
def dispatch(self, request, *args, **kwargs): def dispatch(self, request, *args, **kwargs):
response = super(CompleteView, self).dispatch(request, *args, **kwargs) response = super(CompleteView, self).dispatch(request, *args, **kwargs)
if self.request.user and self.request.user.is_authenticated(): if self.request.user and self.request.user.is_authenticated:
logger.info(smart_text(u"User {} logged in".format(self.request.user.username))) logger.info(smart_text(u"User {} logged in".format(self.request.user.username)))
response.set_cookie('userLoggedIn', 'true') response.set_cookie('userLoggedIn', 'true')
current_user = UserSerializer(self.request.user) current_user = UserSerializer(self.request.user)