What worked in Sqlite3 easily is posing a sudden issue in Postgres (Heroku). I have abstracted quite simply below, the issue of "bcrypt.check_password_hash" not matching the password user provides while logging in with the password saved in the database. None of the solutions to previously asked questions, using encode or converting login password to bytes with utf8 seem to work as I have tried below:
from someproject.model import User, bcrypt
##>> Original password used when signing up: 123 ####
##>> Password was hashed and saved in Database using :
bcrypt.generate_password_hash(password).decode(utf8) ##
## Retrieving hashed password from Database User model ##
user = User.query.filter_by(email='pocofi9623@esmoud.com').first()
print('password saved in postgres database is:',user.password)
output: $2b$12$XK8aUYc9TfFtVtvcow/pPuORPHCXs4GJGCGb3IT4Hjg/EHfq0iQiG
## Password typed in login form : 123 ##
login_password = '123'
### Checking password match using 1 ##
if bcrypt.check_password_hash(user.password.encode(), bytes(login_password, 'utf8')):
print('True')
else:
print('False')
output FALSE
#### Checking password match using 2 ###
if bcrypt.check_password_hash(user.password, bytes(login_password, 'utf8')):
print('True')
else:
print('False')
output FALSE
### Checking password match using 3 ####
if bcrypt.check_password_hash(user.password, login_password):
print('True')
else:
print('False')
output FALSE
Can someone point me in the right direction ?