示例#1
0
def register_extensions(app):
    test_assets.init_app(app) if app.config.get('TESTING') else assets.init_app(app)
    bcrypt.init_app(app)
    cache.init_app(app)
    db.init_app(app)
    login_manager.init_app(app)
    from beacon.models.users import AnonymousUser
    login_manager.anonymous_user = AnonymousUser
    debug_toolbar.init_app(app)
    admin.init_app(app)
    migrate.init_app(app, db)
    s3.init_app(app)
    mail.init_app(app)

    from flask_sslify import SSLify
    # only trigger SSLify if the app is running on Heroku
    if 'DYNO' in os.environ:
        SSLify(app)
    return None
示例#2
0
def register_extensions(app):
    test_assets.init_app(app) if app.config.get(
        'TESTING') else assets.init_app(app)
    bcrypt.init_app(app)
    cache.init_app(app)
    db.init_app(app)
    login_manager.init_app(app)
    from beacon.models.users import AnonymousUser
    login_manager.anonymous_user = AnonymousUser
    debug_toolbar.init_app(app)
    admin.init_app(app)
    migrate.init_app(app, db)
    s3.init_app(app)
    mail.init_app(app)

    from flask_sslify import SSLify
    # only trigger SSLify if the app is running on Heroku
    if 'DYNO' in os.environ:
        SSLify(app)
    return None
示例#3
0
文件: app.py 项目: dobtco/beacon
def register_extensions(app):
    test_assets.init_app(app) if app.config.get('TESTING') else assets.init_app(app)
    cache.init_app(app)
    db.init_app(app)
    debug_toolbar.init_app(app)
    admin.init_app(app)
    migrate.init_app(app, db)
    s3.init_app(app)
    mail.init_app(app)

    from beacon.forms.users import ExtendedRegisterForm
    from beacon.models.users import AnonymousUser, User, Role

    user_datastore = SQLAlchemyUserDatastore(db, User, Role)
    security_ctx = security.init_app(
        app, user_datastore,
        register_form=ExtendedRegisterForm,
        confirm_register_form=ExtendedRegisterForm,
        anonymous_user=AnonymousUser
    )

    from beacon.tasks import send_email
    @security_ctx.send_mail_task
    def async_security_email(msg):
        send_email([msg])

    app.config['SECURITY_MSG_UNAUTHORIZED'] = (
        'You do not have sufficent permissions to do that! If you are staff, make sure you are logged in using the link to the upper right.',
        'alert-warning',
    )

    from flask_sslify import SSLify
    # only trigger SSLify if the app is running on Heroku
    if 'DYNO' in os.environ:
        SSLify(app)
    return None