diff --git a/authentik/stages/password/migrations/0007_app_password.py b/authentik/stages/password/migrations/0007_app_password.py index 50c42488e..fbff951b3 100644 --- a/authentik/stages/password/migrations/0007_app_password.py +++ b/authentik/stages/password/migrations/0007_app_password.py @@ -19,19 +19,6 @@ def update_default_backends(apps: Apps, schema_editor: BaseDatabaseSchemaEditor) stage.save() -def replace_inbuilt(apps: Apps, schema_editor: BaseDatabaseSchemaEditor): - PasswordStage = apps.get_model("authentik_stages_password", "passwordstage") - db_alias = schema_editor.connection.alias - - for stage in PasswordStage.objects.using(db_alias).all(): - if "django.contrib.auth.backends.ModelBackend" not in stage.backends: - continue - stage.backends.remove("django.contrib.auth.backends.ModelBackend") - stage.backends.append(BACKEND_INBUILT) - stage.backends.sort() - stage.save() - - class Migration(migrations.Migration): dependencies = [ diff --git a/authentik/stages/password/migrations/0008_replace_inbuilt.py b/authentik/stages/password/migrations/0008_replace_inbuilt.py new file mode 100644 index 000000000..4c8327e7c --- /dev/null +++ b/authentik/stages/password/migrations/0008_replace_inbuilt.py @@ -0,0 +1,31 @@ +# Generated by Django 3.2.6 on 2021-08-23 14:34 +import django.contrib.postgres.fields +from django.apps.registry import Apps +from django.db import migrations, models +from django.db.backends.base.schema import BaseDatabaseSchemaEditor + +from authentik.stages.password import BACKEND_INBUILT + + +def replace_inbuilt(apps: Apps, schema_editor: BaseDatabaseSchemaEditor): + PasswordStage = apps.get_model("authentik_stages_password", "passwordstage") + db_alias = schema_editor.connection.alias + + for stage in PasswordStage.objects.using(db_alias).all(): + if "django.contrib.auth.backends.ModelBackend" not in stage.backends: + continue + stage.backends.remove("django.contrib.auth.backends.ModelBackend") + stage.backends.append(BACKEND_INBUILT) + stage.backends.sort() + stage.save() + + +class Migration(migrations.Migration): + + dependencies = [ + ("authentik_stages_password", "0007_app_password"), + ] + + operations = [ + migrations.RunPython(replace_inbuilt), + ]