def create(cls, email, password, username='', create_time=datetime.now(), status=USER_STATUS_NORMAL): salt,password = secure.encrypt(password) user = User(salt=salt, password=password, username=username, email=email, create_time=create_time, status=status) db.session.add(user) db.session.commit() return user
def set_password(self, password): salt,en_password = secure.encrypt(password) self.password = en_password self.salt = salt db.session.commit()