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:
parent
ce7653186a
commit
341c00cfb0
1 changed files with 4 additions and 4 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue