Dot-Notation for Users.pw_hash
This commit is contained in:
parent
809cbfc5ab
commit
9047b254f3
@ -82,7 +82,7 @@ def register(request):
|
|||||||
user = request.db.User()
|
user = request.db.User()
|
||||||
user.username = username
|
user.username = username
|
||||||
user.email = email
|
user.email = email
|
||||||
user['pw_hash'] = auth_lib.bcrypt_gen_password_hash(
|
user.pw_hash = auth_lib.bcrypt_gen_password_hash(
|
||||||
request.POST['password'])
|
request.POST['password'])
|
||||||
user.save(validate=True)
|
user.save(validate=True)
|
||||||
|
|
||||||
@ -309,7 +309,7 @@ def verify_forgot_password(request):
|
|||||||
cp_form = auth_forms.ChangePassForm(formdata_vars)
|
cp_form = auth_forms.ChangePassForm(formdata_vars)
|
||||||
|
|
||||||
if request.method == 'POST' and cp_form.validate():
|
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'])
|
request.POST['password'])
|
||||||
user[u'fp_verification_key'] = None
|
user[u'fp_verification_key'] = None
|
||||||
user[u'fp_token_expire'] = None
|
user[u'fp_token_expire'] = None
|
||||||
|
@ -96,7 +96,7 @@ class User(Document):
|
|||||||
See if a user can login with this password
|
See if a user can login with this password
|
||||||
"""
|
"""
|
||||||
return auth_lib.bcrypt_check_password(
|
return auth_lib.bcrypt_check_password(
|
||||||
password, self['pw_hash'])
|
password, self.pw_hash)
|
||||||
|
|
||||||
|
|
||||||
class MediaEntry(Document):
|
class MediaEntry(Document):
|
||||||
|
@ -52,7 +52,7 @@ def adduser(args):
|
|||||||
entry = db.User()
|
entry = db.User()
|
||||||
entry.username = unicode(args.username.lower())
|
entry.username = unicode(args.username.lower())
|
||||||
entry.email = unicode(args.email)
|
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['status'] = u'active'
|
||||||
entry['email_verified'] = True
|
entry['email_verified'] = True
|
||||||
entry.save(validate=True)
|
entry.save(validate=True)
|
||||||
@ -96,7 +96,7 @@ def changepw(args):
|
|||||||
|
|
||||||
user = db.User.one({'username': unicode(args.username.lower())})
|
user = db.User.one({'username': unicode(args.username.lower())})
|
||||||
if user:
|
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()
|
user.save()
|
||||||
print 'Password successfully changed'
|
print 'Password successfully changed'
|
||||||
else:
|
else:
|
||||||
|
@ -29,7 +29,7 @@ def test_get_test_app_wipes_db():
|
|||||||
new_user = mg_globals.database.User()
|
new_user = mg_globals.database.User()
|
||||||
new_user.username = u'lolcat'
|
new_user.username = u'lolcat'
|
||||||
new_user.email = u'lol@cats.example.org'
|
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()
|
new_user.save()
|
||||||
assert mg_globals.database.User.find().count() == 1
|
assert mg_globals.database.User.find().count() == 1
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user