按老师一步一步来的,报错
来源:3-2 Flask实现登录验证
慕神3107089
2021-05-18 11:37:10
@property
def is_authenticated(self):
return True
@property
def is_active(self):
"""有效的用户才能登陆系统"""
return self.status == constants.UserStatus.USER_ACTIVE.value
@property
def is_anonymous(self):
return False
def get_id(self):
return '{}'.format(self.id)
# 1.查找对应的用户
# todo 验证加密后的密码是否正确
user = User.query.filter_by(username=username, password=password).first()
# 2.登录用户
# session['user_id'] = user.id # 将user.id添加到session会话
login_user(user)
{#<div>{{ g.current_user.nickname }}</div>#}
{% if current_user.is_authenticated %}
<div>{{ cuttent_user.nickname }}</div>
{% endif %}
真的疑惑
1回答
时间,
2021-05-18
同学,你好!应该是current_user,同学写错了,因此报错
祝学习愉快!
相似问题