Reputation: 371
I am doing a Flask-login system(by not using inbuilt LoginManager). I have a query to check the username and password which is :
query = s.query(Users).filter(Users.email.in_([POST_email]), Users.password.in_([POST_PASSWORD]) )
result = query.first()
This query is not working. It returns None in the console. Please give a query to check whether the data given in the forms match with the database values.
**
**
This is the function code.
def do_admin_login():
POST_USERNAME = str(request.form['username'])
POST_PASSWORD = str(request.form['password'])
Session = sessionmaker(bind=engine)
s = Session()
query = s.query(Users).filter(Users.email.in_([POST_USERNAME]), Users.password.in_([POST_PASSWORD]) )
result = query.first()
if result:
session['logged_in'] = True
else:
flash('wrong password!')
return home()
The
POST_USERNAME
and
POST_PASSWORD
contain the values that are received from the forms in HTML page. I use Postgres database.
Upvotes: 0
Views: 7781
Reputation: 542
Try this code
query = s.query(Users).filter(Users.email==POST_USERNAME, Users.password==POST_PASSWORD)
Upvotes: 1