Skip to content

Commit

Permalink
add BCRYPT_WORKFACTOR to configuration
Browse files Browse the repository at this point in the history
Closes #62
  • Loading branch information
emillon committed Dec 18, 2014
1 parent ed2a8b4 commit ac64403
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
6 changes: 4 additions & 2 deletions app/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class User(db.Model):
role = db.Column(db.SmallInteger, default=ROLE_USER, nullable=False)
full_name = db.Column(db.String, unique=True, nullable=True)

def __init__(self, login, password, workfactor=12):
def __init__(self, login, password, workfactor=None):
if login is None:
login = 'guest'
self.name = login
Expand Down Expand Up @@ -74,7 +74,9 @@ def generate(fake):
user = User(username, password, workfactor=4)
return user

def set_password(self, clear, workfactor=12):
def set_password(self, clear, workfactor):
if workfactor is None:
workfactor = current_app.config['BCRYPT_WORKFACTOR']
salt = bcrypt.gensalt(workfactor)
self.password = bcrypt.hashpw(clear.encode('utf-8'), salt)

Expand Down
1 change: 1 addition & 0 deletions conf/common.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
PROPAGATE_EXCEPTIONS = True
X_PDFJS_VERSION = '1.0.473'
BCRYPT_WORKFACTOR = 12
1 change: 1 addition & 0 deletions conf/testing.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
SQLALCHEMY_DATABASE_URI = 'sqlite://'
CSRF_ENABLED = False
WTF_CSRF_ENABLED = False
BCRYPT_WORKFACTOR = 4

0 comments on commit ac64403

Please sign in to comment.