pyeve / eve-sqlalchemy

SQLAlchemy data layer for Eve-powered RESTful APIs
http://eve-sqlalchemy.readthedocs.io
Other
234 stars 70 forks source link

some thing is missing in documents #163

Open amoyiki opened 6 years ago

amoyiki commented 6 years ago

I want to run Authentication example code with python3, but not work and raise Unicode-objects must be encoded before hashin

def encrypt(self, password):
        """Encrypt password using hashlib and current salt.
        """
        return str(hashlib.sha1(password + str(self.salt))\
            .hexdigest())

i think above code Should be changed to

def encrypt(self, password):
        """Encrypt password using hashlib and current salt.
        """
        return str(hashlib.sha1((password + str(self.salt)).encode('utf8')).hexdigest())

btw, raise an AttributeError: 'User' object has no attribute 'salt' When i use user.check_password(password) in login method, because current obj has not salt

dkellner commented 6 years ago

Oh well, these examples indeed have not been touched for a long time :). If you have a working solution by now, would me mind creating a PR with a new runnable example in the examples/ directory?

amoyiki commented 6 years ago

@dkellner of course