Added auto admin creation
This commit is contained in:
@@ -59,6 +59,7 @@ def create_sqlite_auth_service(db_path: str,
|
||||
|
||||
def create_auth_app_for_sqlite(db_path: str,
|
||||
jwt_secret: str,
|
||||
create_admin_user: bool = True,
|
||||
email_service: Optional[EmailService] = None):
|
||||
"""
|
||||
Creates an application router designed to use with an SQLite database backend.
|
||||
@@ -69,22 +70,25 @@ def create_auth_app_for_sqlite(db_path: str,
|
||||
|
||||
:param db_path: Path to the SQLite database file.
|
||||
:param jwt_secret: A secret string used for signing and verifying JWT tokens.
|
||||
:param create_admin_user: Create an admin user if necessary.
|
||||
:param email_service: An optional email service instance for managing email-related
|
||||
communication and functionalities during authentication.
|
||||
:return: An application router configured for handling authentication API routes.
|
||||
"""
|
||||
auth_service = create_sqlite_auth_service(db_path, jwt_secret, email_service)
|
||||
if create_admin_user:
|
||||
auth_service.create_admin_if_needed()
|
||||
from .api.routes import create_auth_app
|
||||
return create_auth_app(auth_service)
|
||||
|
||||
|
||||
def create_auth_app_for_mongodb(mongodb_url="mongodb://localhost:27017",
|
||||
jwt_secret="THIS_NEEDS_TO_BE_CHANGED"):
|
||||
jwt_secret="THIS_NEEDS_TO_BE_CHANGED"):
|
||||
raise NotImplementedError("MongoDB support is not yet implemented.")
|
||||
|
||||
|
||||
def create_auth_app_for_postgresql(postgresql_url="mongodb://localhost:27017",
|
||||
username="admin",
|
||||
password="password",
|
||||
jwt_secret="THIS_NEEDS_TO_BE_CHANGED"):
|
||||
username="admin",
|
||||
password="password",
|
||||
jwt_secret="THIS_NEEDS_TO_BE_CHANGED"):
|
||||
raise NotImplementedError("PostgreSQL support is not yet implemented.")
|
||||
|
||||
Reference in New Issue
Block a user