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 292 forks source link

AttributeError: 'User' object has no attribute 'set_active' #253

Open kiza054 opened 5 years ago

kiza054 commented 5 years ago

I have received the following traceback:

Traceback (most recent call last):
  File "/opt/pyenv/versions/3.6.0/lib/python3.6/site-packages/flask/app.py", line 2309, in __call__
    return self.wsgi_app(environ, start_response)
  File "/opt/pyenv/versions/3.6.0/lib/python3.6/site-packages/flask/app.py", line 2295, in wsgi_app
    response = self.handle_exception(e)
  File "/opt/pyenv/versions/3.6.0/lib/python3.6/site-packages/flask/app.py", line 1741, in handle_exception
    reraise(exc_type, exc_value, tb)
  File "/opt/pyenv/versions/3.6.0/lib/python3.6/site-packages/flask/_compat.py", line 35, in reraise
    raise value
  File "/opt/pyenv/versions/3.6.0/lib/python3.6/site-packages/flask/app.py", line 2292, in wsgi_app
    response = self.full_dispatch_request()
  File "/opt/pyenv/versions/3.6.0/lib/python3.6/site-packages/flask/app.py", line 1815, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/opt/pyenv/versions/3.6.0/lib/python3.6/site-packages/flask/app.py", line 1718, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "/opt/pyenv/versions/3.6.0/lib/python3.6/site-packages/flask/_compat.py", line 35, in reraise
    raise value
  File "/opt/pyenv/versions/3.6.0/lib/python3.6/site-packages/flask/app.py", line 1813, in full_dispatch_request
    rv = self.dispatch_request()
  File "/opt/pyenv/versions/3.6.0/lib/python3.6/site-packages/flask/app.py", line 1799, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "/opt/pyenv/versions/3.6.0/lib/python3.6/site-packages/flask_user/views.py", line 67, in confirm_email
    user.set_active(True)
AttributeError: 'User' object has no attribute 'set_active'

Any help will be kindly appreciated

dann254 commented 5 years ago

What is the structure of your user model?

do you have a constructor? like:

# New instance
    def __init__(self, username, email, password, active):
        self.user = username
        self.email = email
        self.password = password
        self.active = active
kiza054 commented 5 years ago

hi dan, i'm using a class which defines a table inside my database

class User(db.Model, UserMixin):
    id = db.Column(db.Integer, primary_key=True)
    username = db.Column(db.String(50), nullable=False, unique=True)
    password = db.Column(db.String(255), nullable=False, server_default='')
    active = db.Column(db.Boolean(), nullable=False, server_default='0')
    email = db.Column(db.String(255), nullable=False, unique=True)
    confirmed_at = db.Column(db.DateTime())

i also have the adapters used within it.

db_adapter = SQLAlchemyAdapter(db, User)
user_manager = UserManager(db_adapter, app)

What is the structure of your user model?

do you have a constructor? like:

# New instance
    def __init__(self, username, email, password, active):
        self.user = username
        self.email = email
        self.password = password
        self.active = active

It all works up until i confirm the email then i get this error