Ejemplo n.º 1
0
class User(UserMixin, db.Model, RBACUserMixin):
    """
    Used by Flask-Security and Flask-Login.
    Represents a user of Security Monkey.
    """
    id = db.Column(db.Integer, primary_key=True)
    email = db.Column(db.String(255), unique=True)
    password = db.Column(db.String(255))
    active = db.Column(db.Boolean())
    confirmed_at = db.Column(db.DateTime())
    daily_audit_email = Column(Boolean())
    change_reports = Column(String(32))  # All, OnlyWithIssues, None

    # Flask-Security SECURITY_TRACKABLE
    last_login_at = Column(DateTime())
    current_login_at = Column(DateTime())
    login_count = Column(Integer)
    # Why 45 characters for IP Address ?
    # See http://stackoverflow.com/questions/166132/maximum-length-of-the-textual-representation-of-an-ipv6-address/166157#166157
    last_login_ip = Column(db.String(45))
    current_login_ip = Column(db.String(45))

    accounts = relationship("Account", secondary=association_table)
    item_audits = relationship("ItemAudit", uselist=False, backref="user")
    revision_comments = relationship("ItemRevisionComment", backref="user")
    item_comments = relationship("ItemComment", backref="user")
    roles = db.relationship('Role',
                            secondary=roles_users,
                            backref=db.backref('users', lazy='dynamic'))
    role = db.Column(db.String(30), default="View")

    def __str__(self):
        return '<User id=%s email=%s>' % (self.id, self.email)
Ejemplo n.º 2
0
class User(db.Model, UserMixin):
    """
    Used by Flask-Security and Flask-Login.
    Represents a user of Security Monkey.
    """
    id = db.Column(db.Integer, primary_key=True)
    email = db.Column(db.String(255), unique=True)
    password = db.Column(db.String(255))
    active = db.Column(db.Boolean())
    confirmed_at = db.Column(db.DateTime())
    daily_audit_email = Column(Boolean())
    change_reports = Column(String(32))  # All, OnlyWithIssues, None
    accounts = relationship("Account", secondary=association_table)
    item_audits = relationship("ItemAudit", uselist=False, backref="user")
    revision_comments = relationship("ItemRevisionComment", backref="user")
    item_comments = relationship("ItemComment", backref="user")
    roles = db.relationship('Role', secondary=roles_users,
                            backref=db.backref('users', lazy='dynamic'))

    def __str__(self):
        return '<User id=%s email=%s>' % (self.id, self.email)