fix(console): create login policy before adding a factor (#10202)

<!--
Please inform yourself about the contribution guidelines on submitting a
PR here:
https://github.com/zitadel/zitadel/blob/main/CONTRIBUTING.md#submit-a-pull-request-pr.
Take note of how PR/commit titles should be written and replace the
template texts in the sections below. Don't remove any of the sections.
It is important that the commit history clearly shows what is changed
and why.
Important: By submitting a contribution you agree to the terms from our
Licensing Policy as described here:
https://github.com/zitadel/zitadel/blob/main/LICENSING.md#community-contributions.
-->

# Which Problems Are Solved

The api call for adding a mfa/2fa factor was running before creating a
login policy.

# How the Problems Are Solved

A new event emitter `beforeTypeAdd` is responsible for taking in a
callback, and then the parent component (login-policy) checks if a login
policy should be created, and then it is successfully created, calls the
callback.
The callback then adds the mfa/2fa factor as before.

# Additional Context

- Closes #9047

Co-authored-by: David Skewis <[email protected]>
Co-authored-by: Stefan Benz <[email protected]>
This commit is contained in:
Mahdi JafariRaviz
2025-10-16 11:12:07 +01:00
committed by GitHub
co-authored by David Skewis Stefan Benz
parent 00beaf6ddc
commit 381727e919
3 changed files with 43 additions and 32 deletions
@@ -55,6 +55,7 @@
[componentType]="LoginMethodComponentType.MultiFactor"
[list]="loginData.multiFactorsList"
(typeRemoved)="removeFactor($event)"
(beforeTypeAdd)="beforeAddFactor($event)"
(typeAdded)="addFactor($event)"
[disabled]="
loginData.passwordlessType === PasswordlessType.PASSWORDLESS_TYPE_NOT_ALLOWED ||
@@ -128,6 +129,7 @@
[componentType]="LoginMethodComponentType.SecondFactor"
[list]="loginData.secondFactorsList"
(typeRemoved)="removeFactor($event)"
(beforeTypeAdd)="beforeAddFactor($event)"
(typeAdded)="addFactor($event)"
[disabled]="
([