Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AttributeError: 'NoneType' object has no attribute 'password' #238

Closed
jackmerrill opened this issue Nov 2, 2018 · 11 comments · May be fixed by #331
Closed

AttributeError: 'NoneType' object has no attribute 'password' #238

jackmerrill opened this issue Nov 2, 2018 · 11 comments · May be fixed by #331

Comments

@jackmerrill
Copy link

Happens if I delete the DB file. Works if I leave it alone for a few.
Nothing with variables, this is all something with Flask-User
Full Traceback:

Traceback (most recent call last):
  File "/home/ec2-user/environment/AmusedGrape/ask/flask/lib/python3.6/dist-packages/flask/app.py", line 2309, in __call__
    return self.wsgi_app(environ, start_response)
  File "/home/ec2-user/environment/AmusedGrape/ask/flask/lib/python3.6/dist-packages/flask/app.py", line 2295, in wsgi_app
    response = self.handle_exception(e)
  File "/home/ec2-user/environment/AmusedGrape/ask/flask/lib/python3.6/dist-packages/flask/app.py", line 1741, in handle_exception
    reraise(exc_type, exc_value, tb)
  File "/home/ec2-user/environment/AmusedGrape/ask/flask/lib/python3.6/dist-packages/flask/_compat.py", line 35, in reraise
    raise value
  File "/home/ec2-user/environment/AmusedGrape/ask/flask/lib/python3.6/dist-packages/flask/app.py", line 2292, in wsgi_app
    response = self.full_dispatch_request()
  File "/home/ec2-user/environment/AmusedGrape/ask/flask/lib/python3.6/dist-packages/flask/app.py", line 1815, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/home/ec2-user/environment/AmusedGrape/ask/flask/lib/python3.6/dist-packages/flask/app.py", line 1718, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "/home/ec2-user/environment/AmusedGrape/ask/flask/lib/python3.6/dist-packages/flask/_compat.py", line 35, in reraise
    raise value
  File "/home/ec2-user/environment/AmusedGrape/ask/flask/lib/python3.6/dist-packages/flask/app.py", line 1813, in full_dispatch_request
    rv = self.dispatch_request()
  File "/home/ec2-user/environment/AmusedGrape/ask/flask/lib/python3.6/dist-packages/flask/app.py", line 1799, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "/home/ec2-user/environment/AmusedGrape/ask/server.py", line 128, in home_page
    return render_template('index.html')
  File "/home/ec2-user/environment/AmusedGrape/ask/flask/lib/python3.6/dist-packages/flask/templating.py", line 133, in render_template
    ctx.app.update_template_context(context)
  File "/home/ec2-user/environment/AmusedGrape/ask/flask/lib/python3.6/dist-packages/flask/app.py", line 792, in update_template_context
    context.update(func())
  File "/home/ec2-user/environment/AmusedGrape/ask/flask/lib/python3.6/dist-packages/flask_login/utils.py", line 368, in _user_context_processor
    return dict(current_user=_get_user())
  File "/home/ec2-user/environment/AmusedGrape/ask/flask/lib/python3.6/dist-packages/flask_login/utils.py", line 335, in _get_user
    current_app.login_manager._load_user()
  File "/home/ec2-user/environment/AmusedGrape/ask/flask/lib/python3.6/dist-packages/flask_login/login_manager.py", line 359, in _load_user
    return self.reload_user()
  File "/home/ec2-user/environment/AmusedGrape/ask/flask/lib/python3.6/dist-packages/flask_login/login_manager.py", line 321, in reload_user
    user = self.user_callback(user_id)
  File "/home/ec2-user/environment/AmusedGrape/ask/flask/lib/python3.6/dist-packages/flask_user/user_manager.py", line 130, in load_user_by_user_token
    user = self.db_manager.UserClass.get_user_by_token(user_token)
  File "/home/ec2-user/environment/AmusedGrape/ask/flask/lib/python3.6/dist-packages/flask_user/user_mixin.py", line 52, in get_user_by_token
    user_password = '' if user_manager.USER_ENABLE_AUTH0 else user.password[-8:]
AttributeError: 'NoneType' object has no attribute 'password'
@jackmerrill
Copy link
Author

Can confirm,This is an issue with Flask-User.

@jackmerrill
Copy link
Author

Everything works if I remove the UserManager class from my code. It is an issue with Flask-User.

@lingthio
Copy link
Owner

lingthio commented Nov 3, 2018

I've been a bit swamped lately. Care to submit a fix as a pull request? -- Ling

@ghost
Copy link

ghost commented Nov 3, 2018

@yoshifan509 which Python version are you using? I have this problem with Python 3.7

@ghost
Copy link

ghost commented Nov 5, 2018

It also happens when you delete a single user from the database and then reload the url you are in or even the base url for the website. It works again if you delete the session cookie

@jackmerrill
Copy link
Author

@saitam1 I am using 3.6.5.
I'll try to delete the session cookies.
I cleared the browser cookies and that seemed to fix it.

@ghost
Copy link

ghost commented Nov 29, 2018

@yoshifan509 Is deleting the cookie a good solution for this problem? Don't you think we should let the issue open until somebody fixes it inside the code?

@bkgoodman
Copy link

Deleting cookies worked for me - but really should be fixed for "real".

@papak69
Copy link

papak69 commented Jul 16, 2019

is there anyway i can "force" delete cookie for user if the user was deleted from db?

@colaisr
Copy link

colaisr commented May 24, 2020

confirm it still happens ...when removing db.. but not everytime...first time a day after several deletes redos

@wenjie0909
Copy link

Hi,

I just change the code in user_mixin.py as following, and it seems works:

after: user_password = '' if user_manager.USER_ENABLE_AUTH0 or user == None else user.password[-8:]
before: user_password = '' if user_manager.USER_ENABLE_AUTH0 else user.password[-8:]

MichaelMa2014 added a commit to MichaelMa2014/Flask-User that referenced this issue Mar 8, 2021
Fixes lingthio#238 AttritbuteError: 'NoneType' object has no attribute 'password'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
6 participants