a guest May 31st, 2017 58 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
- class User(Document):
- email = StringField(required=True)
- username = StringField(required=True)
- password = StringField(required=True)
- salt = StringField(required=True)
- def create(cls, email, username, password):
- '''Call this method instead of directly instiating yourself.
- This will correctly salt the password in the database.
- Returns a User object
- salt = gen_random_string(random.randint(5, 30))
- salted = sha512(salt + password).hexdigest()
- user = User(email=email, username=username, password=salted,
- return user
- def __eq__(self, other):
- return sha512(self.salt + other) == self.password
RAW Paste Data