# Path: doorman/database.py
# class CRUDMixin(object):
# class Model(CRUDMixin, db.Model):
# class SurrogatePK(object):
#     def create(cls, **kwargs):
#     def update(self, commit=True, **kwargs):
#     def save(self, commit=True):
#     def delete(self, commit=True):
#     def get_by_id(cls, record_id):
# def reference_col(tablename, nullable=False, pk_name='id', **kwargs):
# 
# Path: doorman/extensions.py
# class LogTee(object):
# class RuleManager(object):
#     class ContextTask(TaskBase):
#     def __init__(self, app=None):
#     def init_app(self, app):
#     def handle_status(self, data, **kwargs):
#     def handle_result(self, data, **kwargs):
#     def __init__(self, app=None):
#     def init_app(self, app):
#     def load_alerters(self):
#     def should_reload_rules(self):
#     def load_rules(self):
#     def handle_log_entry(self, entry, node):
# def make_celery(app, celery):
#         def __call__(self, *args, **kwargs):


import datetime as dt
import string
import uuid
from flask_login import UserMixin
from doorman.database import (
    Column,
    Table,
    ForeignKey,
    Index,
    Model,
    SurrogatePK,
    db,
    reference_col,
    relationship,
    ARRAY,
    JSONB,
    INET,
    declared_attr,
)
from doorman.extensions import bcrypt
        from doorman.utils import assemble_configuration
        from doorman.utils import assemble_distributed_queries
    email = Column(db.String)

    password = Column(db.String, nullable=True)
    created_at = Column(db.DateTime, nullable=False, default=dt.datetime.utcnow)

    # oauth related stuff
    social_id = Column(db.String)
    first_name = Column(db.String)
    last_name = Column(db.String)

    def __init__(self, username, password=None, email=None, social_id=None,
                 first_name=None, last_name=None):
        self.username = username
        self.email = email
        if password:
            self.set_password(password)
        else:
            self.password = None

        self.social_id = social_id
        self.first_name = first_name
        self.last_name = last_name

    def set_password(self, password):
        self.update(password=bcrypt.generate_password_hash(password))
        return

    def check_password(self, value):
        if not self.password:
            # still do the computation

# Path: doorman/database.py
# class CRUDMixin(object):
# class Model(CRUDMixin, db.Model):
# class SurrogatePK(object):
#     def create(cls, **kwargs):
#     def update(self, commit=True, **kwargs):
#     def save(self, commit=True):
#     def delete(self, commit=True):
#     def get_by_id(cls, record_id):
# def reference_col(tablename, nullable=False, pk_name='id', **kwargs):
# 
# Path: doorman/extensions.py
# class LogTee(object):
# class RuleManager(object):
#     class ContextTask(TaskBase):
#     def __init__(self, app=None):
#     def init_app(self, app):
#     def handle_status(self, data, **kwargs):
#     def handle_result(self, data, **kwargs):
#     def __init__(self, app=None):
#     def init_app(self, app):
#     def load_alerters(self):
#     def should_reload_rules(self):
#     def load_rules(self):
#     def handle_log_entry(self, entry, node):
# def make_celery(app, celery):
#         def __call__(self, *args, **kwargs):


# Path: doorman/models.py
import datetime as dt
import string
import uuid
from flask_login import UserMixin
from doorman.database import (
    Column,
    Table,
    ForeignKey,
    Index,
    Model,
    SurrogatePK,
    db,
    reference_col,
    relationship,
    ARRAY,
    JSONB,
    INET,
    declared_attr,
)
from doorman.extensions import bcrypt
        from doorman.utils import assemble_configuration
        from doorman.utils import assemble_distributed_queries

    email = Column(db.String)

    password = Column(db.String, nullable=True)
    created_at = Column(db.DateTime, nullable=False, default=dt.datetime.utcnow)

    # oauth related stuff
    social_id = Column(db.String)
    first_name = Column(db.String)
    last_name = Column(db.String)

    def __init__(self, username, password=None, email=None, social_id=None,
                 first_name=None, last_name=None):
        self.username = username
        self.email = email
        if password:
            self.set_password(password)
        else:
            self.password = None

        self.social_id = social_id
        self.first_name = first_name
        self.last_name = last_name

    def set_password(self, password):
        self.update(password=bcrypt.generate_password_hash(password))
        return

    def check_password(self, value):
        if not self.password:
            # still do the computation

            return bcrypt.generate_password_hash(value) and False