I want to modify is_active
in Flask-Login so that users are not always active.
The default always returns True
, but I changed it to return the value of the banned
column.
Based on the docs, is_active
should be a property. However, the internal Flask-Login code raises:
TypeError: 'bool' object is not callable
When trying to use is_active
.
How do I correctly use is_active
to deactivate some users?
class User(UserMixin, db.Model):
id = db.Column(db.Integer, primary_key=True)
banned = db.Column(db.Boolean, default=False)
@property
def is_active(self):
return self.banned
login_user(user, form.remember_me.data)
if not force and not user.is_active():
TypeError: 'bool' object is not callable
Question&Answers:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…