1
0
Fork 0
mirror of https://codeberg.org/Mo8it/AdvLabDB.git synced 2024-12-04 22:40:30 +00:00

Use init_app for Security

This commit is contained in:
Mo 2022-11-10 13:20:32 +01:00
parent ce7653186a
commit 341c00cfb0

View file

@ -1,5 +1,6 @@
from flask_migrate import Migrate
from flask_security.datastore import SQLAlchemyUserDatastore
from flask_security.core import Security
from .config import get_settings, get_data_dir
from .models import db, User, Role
@ -11,6 +12,8 @@ settings = get_settings(data_dir)
user_datastore = SQLAlchemyUserDatastore(db, User, Role)
security = Security(datastore=user_datastore)
def create_app(create_for_server: bool = True):
from flask import Flask
@ -23,16 +26,13 @@ def create_app(create_for_server: bool = True):
set_config(app, data_dir)
# Setup Flask-SQLAlchemy
db.init_app(app)
# Setup Flask-Migrate
migrate.init_app(app, db)
# Setup Flask-Security-Too
from flask_security.core import Security
Security(app, user_datastore)
security.init_app(app)
if create_for_server:
# Setup views