This commit is contained in:
Antonio de la Rosa 2015-12-07 21:47:23 +01:00
parent 20becdbd27
commit b2fba8870f
33 changed files with 3958 additions and 38 deletions

View file

@ -0,0 +1,49 @@
from paramecio.cromosoma.corefields import PhangoField
from paramecio.cromosoma.coreforms import PasswordForm
from passlib.hash import bcrypt
class PasswordField(PhangoField):
def __init__(self, name, size=255, required=False):
super(PasswordField, self).__init__(name, size, required)
self.protected=True
self.name_form=PasswordForm
self.default_value=''
def check(self, value):
self.txt_error=''
self.error=False
value.strip()
if value=='':
if self.model!=None:
if self.model.updated==True:
self.required=False
self.check_blank=True
return ""
else:
self.txt_error="The value is empty"
self.error=True
else:
self.txt_error="The value is empty"
self.error=True
else:
value = bcrypt.encrypt(value)
return value
@staticmethod
def verify( password, h):
return bcrypt.verify(password, h)