added gen_password_hash and check_password functions to auth/__init__

This commit is contained in:
Rodney Ewing 2013-05-23 13:28:03 -07:00
parent 57e8be21bc
commit b194f29fe3
3 changed files with 13 additions and 3 deletions

View File

@ -53,5 +53,10 @@ def gen_password_hash(raw_pass, extra_salt=None):
return hook_handle("auth_gen_password_hash", raw_pass, extra_salt)
def check_password(raw_pass, stored_hash, extra_salt=None):
return hook_handle("auth_check_password",
raw_pass, stored_hash, extra_salt)
def fake_login_attempt():
return hook_handle("auth_fake_login_attempt")

View File

@ -71,6 +71,10 @@ def gen_password_hash(raw_pass, extra_salt):
return auth_lib.bcrypt_gen_password_hash(raw_pass, extra_salt)
def check_password(raw_pass, stored_hash, extra_salt):
return auth_lib.bcrypt_check_password(raw_pass, stored_hash, extra_salt)
def auth():
return True
@ -94,6 +98,7 @@ hooks = {
'auth_get_login_form': get_login_form,
'auth_get_registration_form': get_registration_form,
'auth_gen_password_hash': gen_password_hash,
'auth_check_password': check_password,
'auth_fake_login_attempt': auth_lib.fake_login_attempt,
'template_global_context': append_to_global_context,
('mediagoblin.plugins.openid.register',

View File

@ -21,7 +21,7 @@ from mediagoblin import mg_globals
from mediagoblin.db.models import User
from mediagoblin.tests.tools import fixture_add_user
from mediagoblin.tools import template
from mediagoblin.plugins.basic_auth.lib import bcrypt_check_password
from mediagoblin import auth
class TestUserEdit(object):
@ -75,7 +75,7 @@ class TestUserEdit(object):
# test_user has to be fetched again in order to have the current values
test_user = User.query.filter_by(username=u'chris').first()
assert bcrypt_check_password('123456', test_user.pw_hash)
assert auth.check_password('123456', test_user.pw_hash)
# Update current user passwd
self.user_password = '123456'
@ -89,7 +89,7 @@ class TestUserEdit(object):
})
test_user = User.query.filter_by(username=u'chris').first()
assert not bcrypt_check_password('098765', test_user.pw_hash)
assert not auth.check_password('098765', test_user.pw_hash)
def test_change_bio_url(self, test_app):