Added check for user on the request object

Make sure the user object exists before checking authentication to prevent AttributeError: 'WSGIRequest' object has no attribute 'user'