-
@auth.route('/login', methods=['GET', 'POST'])
-
def login():
-
form = LoginForm()
-
if form.validate_on_submit():
-
user = User.query.filter_by(email=form.email.data).first()
-
if user is not None and user.verify_password(form.password.data):
-
login_user(user, form.remember_me.data)
-
return redirect(request.args.get('next') or url_for('main.index'))
-
flash('Invalid username or password.')
-
return render_template('auth/login.html', form=form)
-
class User(db.Model):
-
__tablename__ = 'users'
-
id = db.Column(db.Integer, primary_key=True)
-
email = db.Column(db.String(64),unique=True,index=True)
-
username = db.Column(db.String(64), unique=True, index=True)
-
password_hash = db.Column(db.String(128))
-
role_id = db.Column(db.Integer, db.ForeignKey('roles.id'))
User这个数据库模型里面没有is_active,你的user,没有继承,UserMixin,
点击(此处)折叠或打开