Skip to content

Commit

Permalink
Remove workfactor logic
Browse files Browse the repository at this point in the history
  • Loading branch information
emillon committed Jan 30, 2015
1 parent 6eb7351 commit 1cc7803
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 9 deletions.
12 changes: 5 additions & 7 deletions app/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,14 @@ class User(db.Model):
full_name = db.Column(db.String, nullable=True)
only_doc_id = db.Column(db.Integer, nullable=True)

def __init__(self, login, password, workfactor=None):
def __init__(self, login, password):
if login is None:
login = 'guest'
self.name = login
if password is None:
self.disable_password()
else:
self.set_password(password, workfactor=workfactor)
self.set_password(password)

def is_active(self):
"""
Expand Down Expand Up @@ -74,14 +74,12 @@ def is_admin(self):
def generate(fake):
username = fake.user_name()
password = fake.password()
user = User(username, password, workfactor=4)
user = User(username, password)
return user

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

def disable_password(self):
self.password = '!'
Expand Down
2 changes: 1 addition & 1 deletion conf/common.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
PROPAGATE_EXCEPTIONS = True
X_PDFJS_VERSION = '1.0.473'
BCRYPT_WORKFACTOR = 12
BCRYPT_LOG_ROUNDS = 12
2 changes: 1 addition & 1 deletion conf/testing.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
SQLALCHEMY_DATABASE_URI = 'sqlite://'
CSRF_ENABLED = False
WTF_CSRF_ENABLED = False
BCRYPT_WORKFACTOR = 4
BCRYPT_LOG_ROUNDS = 4

0 comments on commit 1cc7803

Please sign in to comment.