From bff7addb5557efcdc2a4bbdd2aa6bfdd2b94167e Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Sat, 21 Aug 2021 15:15:45 +0200 Subject: [PATCH] stages/password: adjust name of default prompt stage Signed-off-by: Jens Langhammer --- .../0002_passwordstage_change_flow.py | 2 +- .../migrations/0006_passwordchange_rename.py | 27 +++++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 authentik/stages/password/migrations/0006_passwordchange_rename.py diff --git a/authentik/stages/password/migrations/0002_passwordstage_change_flow.py b/authentik/stages/password/migrations/0002_passwordstage_change_flow.py index edfc206d1..73686f08a 100644 --- a/authentik/stages/password/migrations/0002_passwordstage_change_flow.py +++ b/authentik/stages/password/migrations/0002_passwordstage_change_flow.py @@ -27,7 +27,7 @@ def create_default_password_change(apps: Apps, schema_editor: BaseDatabaseSchema ) prompt_stage, _ = PromptStage.objects.using(db_alias).update_or_create( - name="Change your password", + name="default-password-change-prompt", ) password_prompt, _ = Prompt.objects.using(db_alias).update_or_create( field_key="password", diff --git a/authentik/stages/password/migrations/0006_passwordchange_rename.py b/authentik/stages/password/migrations/0006_passwordchange_rename.py new file mode 100644 index 000000000..e3f24799f --- /dev/null +++ b/authentik/stages/password/migrations/0006_passwordchange_rename.py @@ -0,0 +1,27 @@ +# Generated by Django 3.2.5 on 2021-08-21 13:12 +from django.apps.registry import Apps +from django.db import migrations +from django.db.backends.base.schema import BaseDatabaseSchemaEditor + + +def rename_default_prompt_stage(apps: Apps, schema_editor: BaseDatabaseSchemaEditor): + PromptStage = apps.get_model("authentik_stages_prompt", "PromptStage") + db_alias = schema_editor.connection.alias + + stages = PromptStage.objects.using(db_alias).filter(name="Change your password") + if not stages.exists(): + return + stage = stages.first() + stage.name = "default-password-change-prompt" + stage.save() + + +class Migration(migrations.Migration): + + dependencies = [ + ("authentik_stages_password", "0005_auto_20210402_2221"), + ] + + operations = [ + migrations.RunPython(rename_default_prompt_stage), + ]