Generic user hash
Sometimes we need to generate our own hash value for a user. To implement this:
- Add
PEPPER
as a system config value - Add
salt
as an attribute on the User model (populated when User object is created) - Add
hash
as a function on the User model:
def hash(input, hash_function="bcrypt"):
if hash_function == "bcrypt":
return bcrypt.hashpw(input, user.salt + system.PEPPER)
else:
throw UnknownFunctionError