Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class User(db.Document, UserMixin):
- username = db.StringField(max_length=80)
- email = db.StringField(max_length=255, unique=True)
- password = db.StringField(max_length=255, required=True)
- active = db.BooleanField(default=True)
- def __init__(self, *args, **kwargs):
- super(db.Document, self).__init__(self)
- try:
- self.username = kwargs['username']
- self.email = kwargs['email']
- self.password = kwargs['password']
- except:
- flash('Bad arguments for User')
- @staticmethod
- def salt_password(password):
- return generate_password_hash(password)
- @property
- def is_authenticated(self):
- return True
- @property
- def is_active(self):
- return self.active
- @property
- def is_anonymous(self):
- return False
- def get_id(self):
- return unicode(self._id)
- def __repr__(self):
- return '<User %r>' % (self.username)
- def check_pwd(self, password):
- return check_password_hash(self.password, password)
- class User(db.Document, UserMixin):
- _id = db.ObjectIdField(default=bson.ObjectId())
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement