Skip to content
This repository has been archived by the owner on Feb 22, 2024. It is now read-only.

AttributeError: 'AnonymousUserMixin' object has no attribute 'id' #178

Closed
libbkmz opened this issue Nov 6, 2013 · 6 comments
Closed

AttributeError: 'AnonymousUserMixin' object has no attribute 'id' #178

libbkmz opened this issue Nov 6, 2013 · 6 comments

Comments

@libbkmz
Copy link

libbkmz commented Nov 6, 2013

I get this strange error randomly. To fix i clear the cookies of used domain. And now, i found the fix, after which i can't get this error again:
core.py

def _identity_loader():
    if not isinstance(current_user._get_current_object(), AnonymousUser):
        identity = Identity(current_user.id)
        return identity

To:

def _identity_loader():
    if not isinstance(current_user._get_current_object(), AnonymousUser) and \
       not isinstance(current_user._get_current_object(), AnonymousUserMixin):
        identity = Identity(current_user.id)
        return identity

When I'll get this error again, i'll post the full traceback

@libbkmz
Copy link
Author

libbkmz commented Nov 28, 2013

This is full tracback:

Exception on /cat/1 [GET]
Traceback (most recent call last):
  File "/app_venv/local/lib/python2.7/site-packages/flask/app.py", line 1817, in wsgi_app
    response = self.full_dispatch_request()
  File "/app_venv/local/lib/python2.7/site-packages/flask/app.py", line 1477, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/app_venv/local/lib/python2.7/site-packages/flask/app.py", line 1381, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "/app_venv/local/lib/python2.7/site-packages/flask/app.py", line 1475, in full_dispatch_request
    rv = self.dispatch_request()
  File "/app_venv/local/lib/python2.7/site-packages/flask/app.py", line 1461, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "/app_venv/flaskr/psw/views.py", line 76, in decorated_func
    access_list = AccessList.query.filter(AccessList.user_id == current_user.id).all()
  File "/app_venv/local/lib/python2.7/site-packages/werkzeug/local.py", line 338, in __getattr__
    return getattr(self._get_current_object(), name)
AttributeError: 'AnonymousUserMixin' object has no attribute 'id'

@libbkmz
Copy link
Author

libbkmz commented Nov 28, 2013

@mattupstate
Copy link
Collaborator

Somehow the AnonymousUserMixin object is being used as your anonymous user object class. This is most likely due to a configuration problem.

@libbkmz
Copy link
Author

libbkmz commented Dec 19, 2013

Any suggestions?

@mattupstate
Copy link
Collaborator

@libbkmz I can't make any suggestions unless I was able to see your code.

@eriktaubeneck
Copy link

I'm not sure how you are using the access_list, but you may just need to put a @login_required decorator on the route before you apply whatever access decorator you've come up with (i.e., below it) which will redirect a non-logged in user before your access_list stuff happens.

galeo pushed a commit to galeo/flask-security-outdated that referenced this issue Mar 4, 2020
Continue converting to Pallet's sphinx style - this changed the sidebars - we no longer
need our own versions.

Change logo from helmut/armor to owl...

Made content/first page more like flask.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

No branches or pull requests

3 participants