Dot-Notation for Users.pw_hash
authorElrond <elrond+mediagoblin.org@samba-tng.org>
Mon, 14 Nov 2011 17:49:21 +0000 (18:49 +0100)
committerElrond <elrond+mediagoblin.org@samba-tng.org>
Mon, 5 Dec 2011 20:08:57 +0000 (21:08 +0100)
mediagoblin/auth/views.py
mediagoblin/db/models.py
mediagoblin/gmg_commands/users.py
mediagoblin/tests/test_tests.py

index f8e842850857992be636acdf892540f02c96fb47..63bf9a91a3c02bff13e8455f75348a439ec687dc 100644 (file)
@@ -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
index 4af996b88642fc666c9772956bb79a1172018e58..795cba6ad7b7dd14a3154dc9b6388814682584e8 100644 (file)
@@ -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):
index 04d88e23d15fdd2e4802f3f4c65fab849c708be7..6084f9d7c67c7b815d061c21bb920b59ccb7659d 100644 (file)
@@ -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:
index b3a5c2fa6a5106bb2ad810f24173f0dd3e034fd6..25bb52b3f17046b7eac1e5604e91d739976bb9f8 100644 (file)
@@ -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