Fixes in password hash for avoid limit character bugs in bcrypt

This commit is contained in:
Antonio de la Rosa 2016-04-04 03:34:21 +02:00
parent 2d6f6da098
commit 46b18e0dde
3 changed files with 6 additions and 5 deletions

View file

@ -1,4 +1,4 @@
${show_flash_message()|n} ${show_flash_message()|n}
<h1>${admin.title}</h1> <h1>${admin.title}</h1>
<a href="${add_get_parameters(admin.url, op_admin='1')}">${lang('common', 'add_item', 'Add new item')}</a> <a href="${add_get_parameters(admin.url, op_admin='1')}">${lang('common', 'add_item', 'Add new item')}</a>
${admin.list.show()|n} ${admin.list.show()|n}

View file

@ -1,6 +1,7 @@
from paramecio.cromosoma.corefields import PhangoField from paramecio.cromosoma.corefields import PhangoField
from paramecio.cromosoma.coreforms import PasswordForm from paramecio.cromosoma.coreforms import PasswordForm
from passlib.hash import bcrypt #from passlib.hash import bcrypt
from passlib.hash import bcrypt_sha256
class PasswordField(PhangoField): class PasswordField(PhangoField):
@ -36,7 +37,7 @@ class PasswordField(PhangoField):
self.error=True self.error=True
else: else:
value = bcrypt.encrypt(value) value = bcrypt_sha256.encrypt(value)
return value return value
@ -44,6 +45,6 @@ class PasswordField(PhangoField):
@staticmethod @staticmethod
def verify( password, h): def verify( password, h):
return bcrypt.verify(password, h) return bcrypt_sha256.verify(password, h)

View file

@ -9,7 +9,7 @@
url: "${make_url('admin/register')}", url: "${make_url('admin/register')}",
method: "POST", method: "POST",
dataType: "json", dataType: "json",
data: {'username': $('#username_form').val(), 'email': $('#email_form').val(), 'password': $('#password_form').val(), 'repeat_password': $('#repeat_password_form').val()} data: {'username': $('#username_form').val(), 'email': $('#email_form').val(), 'password': $('#password_form').val(), 'repeat_password': $('#repeat_password_form').val(), 'csrf_token': $('#csrf_token').val()}
}).done(function(data) { }).done(function(data) {
//$( this ).addClass( "done" ); //$( this ).addClass( "done" );
//Redirect if register //Redirect if register