From 9047b254f340c16f33183f0d6d68e6c4a5a3c8de Mon Sep 17 00:00:00 2001 From: Elrond Date: Mon, 14 Nov 2011 18:49:21 +0100 Subject: [PATCH] Dot-Notation for Users.pw_hash --- mediagoblin/auth/views.py | 4 ++-- mediagoblin/db/models.py | 2 +- mediagoblin/gmg_commands/users.py | 4 ++-- mediagoblin/tests/test_tests.py | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/mediagoblin/auth/views.py b/mediagoblin/auth/views.py index f8e84285..63bf9a91 100644 --- a/mediagoblin/auth/views.py +++ b/mediagoblin/auth/views.py @@ -82,7 +82,7 @@ def register(request): user = request.db.User() user.username = username user.email = email - user['pw_hash'] = auth_lib.bcrypt_gen_password_hash( + user.pw_hash = auth_lib.bcrypt_gen_password_hash( request.POST['password']) user.save(validate=True) @@ -309,7 +309,7 @@ def verify_forgot_password(request): cp_form = auth_forms.ChangePassForm(formdata_vars) if request.method == 'POST' and cp_form.validate(): - user[u'pw_hash'] = auth_lib.bcrypt_gen_password_hash( + user.pw_hash = auth_lib.bcrypt_gen_password_hash( request.POST['password']) user[u'fp_verification_key'] = None user[u'fp_token_expire'] = None diff --git a/mediagoblin/db/models.py b/mediagoblin/db/models.py index 4af996b8..795cba6a 100644 --- a/mediagoblin/db/models.py +++ b/mediagoblin/db/models.py @@ -96,7 +96,7 @@ class User(Document): See if a user can login with this password """ return auth_lib.bcrypt_check_password( - password, self['pw_hash']) + password, self.pw_hash) class MediaEntry(Document): diff --git a/mediagoblin/gmg_commands/users.py b/mediagoblin/gmg_commands/users.py index 04d88e23..6084f9d7 100644 --- a/mediagoblin/gmg_commands/users.py +++ b/mediagoblin/gmg_commands/users.py @@ -52,7 +52,7 @@ def adduser(args): entry = db.User() entry.username = unicode(args.username.lower()) entry.email = unicode(args.email) - entry['pw_hash'] = auth_lib.bcrypt_gen_password_hash(args.password) + entry.pw_hash = auth_lib.bcrypt_gen_password_hash(args.password) entry['status'] = u'active' entry['email_verified'] = True entry.save(validate=True) @@ -96,7 +96,7 @@ def changepw(args): user = db.User.one({'username': unicode(args.username.lower())}) if user: - user['pw_hash'] = auth_lib.bcrypt_gen_password_hash(args.password) + user.pw_hash = auth_lib.bcrypt_gen_password_hash(args.password) user.save() print 'Password successfully changed' else: diff --git a/mediagoblin/tests/test_tests.py b/mediagoblin/tests/test_tests.py index b3a5c2fa..25bb52b3 100644 --- a/mediagoblin/tests/test_tests.py +++ b/mediagoblin/tests/test_tests.py @@ -29,7 +29,7 @@ def test_get_test_app_wipes_db(): new_user = mg_globals.database.User() new_user.username = u'lolcat' new_user.email = u'lol@cats.example.org' - new_user['pw_hash'] = u'pretend_this_is_a_hash' + new_user.pw_hash = u'pretend_this_is_a_hash' new_user.save() assert mg_globals.database.User.find().count() == 1 -- 2.25.1