stages/password: fix replace_inbuilt not being called
Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
parent
cff37caa57
commit
dec34bc948
|
@ -19,19 +19,6 @@ def update_default_backends(apps: Apps, schema_editor: BaseDatabaseSchemaEditor)
|
||||||
stage.save()
|
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):
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
dependencies = [
|
dependencies = [
|
||||||
|
|
31
authentik/stages/password/migrations/0008_replace_inbuilt.py
Normal file
31
authentik/stages/password/migrations/0008_replace_inbuilt.py
Normal file
|
@ -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),
|
||||||
|
]
|
Reference in a new issue