lingthio / Flask-User

Customizable User Authorization & User Management: Register, Confirm, Login, Change username/password, Forgot password and more.
http://flask-user.readthedocs.io/
MIT License
1.06k stars 294 forks source link

type object 'User' has no attribute 'get_user_by_token' #301

Open MajorTomaso opened 4 years ago

MajorTomaso commented 4 years ago

I get this feedback after logging in:

Traceback (most recent call last):
  File "c:\users\asus\appdata\local\programs\python\python38-32\lib\site-packages\flask\app.py", line 2446, in wsgi_app
    response = self.full_dispatch_request()
  File "c:\users\asus\appdata\local\programs\python\python38-32\lib\site-packages\flask\app.py", line 1951, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "c:\users\asus\appdata\local\programs\python\python38-32\lib\site-packages\flask\app.py", line 1820, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "c:\users\asus\appdata\local\programs\python\python38-32\lib\site-packages\flask\_compat.py", line 39, in reraise
    raise value
  File "c:\users\asus\appdata\local\programs\python\python38-32\lib\site-packages\flask\app.py", line 1949, in full_dispatch_request
    rv = self.dispatch_request()
  File "c:\users\asus\appdata\local\programs\python\python38-32\lib\site-packages\flask\app.py", line 1935, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "C:\Users\asus\Desktop\group-17-electronic-voting-system\vote\routes.py", line 12, in home
    return render_template('home.html',title='Home')
  File "c:\users\asus\appdata\local\programs\python\python38-32\lib\site-packages\flask\templating.py", line 136, in render_template
    ctx.app.update_template_context(context)
  File "c:\users\asus\appdata\local\programs\python\python38-32\lib\site-packages\flask\app.py", line 838, in update_template_context
    context.update(func())
  File "c:\users\asus\appdata\local\programs\python\python38-32\lib\site-packages\flask_login\utils.py", line 379, in _user_context_processor
    return dict(current_user=_get_user())
  File "c:\users\asus\appdata\local\programs\python\python38-32\lib\site-packages\flask_login\utils.py", line 346, in _get_user
    current_app.login_manager._load_user()
  File "c:\users\asus\appdata\local\programs\python\python38-32\lib\site-packages\flask_login\login_manager.py", line 318, in _load_user
    user = self._user_callback(user_id)
  File "c:\users\asus\appdata\local\programs\python\python38-32\lib\site-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)
AttributeError: type object 'User' has no attribute 'get_user_by_token'

Any help would be appreciated

crakernano commented 4 years ago

+1

same issue

MRodriguez08 commented 3 years ago

+1

MRodriguez08 commented 3 years ago

@crakernano @MajorTomaso Seems that the version of Flask-User expects a method 'get_user_by_token' with the same algorithm as load_user in the User model: image

Hope this help!

GotPythonized commented 3 years ago

Just got this error. Fixed with:

from flask_user import UserMixin

Then:

image