I ran into a similar problem. Here is a copy of the last part of my stack trace:
self.password = User.hashed_password(password)
File "/app/application/models.py", line 16, in hashed_password
File "/app/.heroku/python/lib/python3.5/site-packages/flask_bcrypt.py", line 163, in generate_password_hash
File "/app/.heroku/python/lib/python3.5/site-packages/bcrypt/__init__.py", line 50, in gensalt
output = _bcrypt.ffi.new("unsigned char[]", 30)
AttributeError: module 'bcrypt._bcrypt' has no attribute 'ffi'
, Heroku. - . Bcrypt () Flask Heroku.
1
. , cryptography requirements.txt. , , , . , - .
2
Flask, / werkzeug.security / , bcrypt. models.py, , .
from index import db
from werkzeug.security import generate_password_hash, check_password_hash
class User(db.Model):
id = db.Column(db.Integer(), primary_key=True)
email = db.Column(db.String(255), unique=True)
password = db.Column(db.String(255))
def __init__(self, email, password):
self.email = email
self.active = True
self.password = User.hashed_password(password)
@staticmethod
def hashed_password(password):
return generate_password_hash(password)
@staticmethod
def get_user_with_email_and_password(email, password):
user = User.query.filter_by(email=email).first()
if user and check_password_hash(user.password, password):
return user
else:
return None