Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class User(UserMixin, db.Model):
- """
- Create an User table
- """
- __tablename__ = 'users'
- id = db.Column(db.Integer, primary_key=True)
- email = db.Column(db.String(), index=True, unique=True)
- username = db.Column(db.String(), index=True, unique=True)
- first_name = db.Column(db.String(), index=True)
- last_name = db.Column(db.String(), index=True)
- password_hash = db.Column(db.String())
- @property
- def password(self):
- """
- Prevent pasword from being accessed
- """
- raise AttributeError('password is not a readable attribute.')
- @password.setter
- def password(self, password):
- """
- Set password to a hashed password
- """
- self.password_hash = generate_password_hash(password)
- def verify_password(self, password):
- """
- Check if hashed password matches actual password
- """
- return check_password_hash(self.password_hash, password)
- def __repr__(self):
- return '<User: {}>'.format(self.username)
- class Account(db.Model):
- """
- Create a Service Account table
- """
- __tablename__ = "accounts"
- id = db.Column(db.Integer, primary_key=True)
- service = db.Column(db.String(), index=True)
- account_login = db.Column(db.String(), index=True, unique=True)
- account_password = db.Column(db.String())
- owner_id = db.Column(db.Integer, index=True)
- @property
- def password(self):
- """
- Prevent pasword from being accessed
- """
- raise AttributeError('password is not a readable attribute.')
- @password.setter
- def password(self, password):
- """
- Set password to a hashed password
- """
- self.account_password = generate_password_hash(password)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement