mirror of
https://github.com/andwati/zitadel.git
synced 2026-11-13 09:25:12 +00:00
* features * features * features * fix json tags * add features handler to auth * mocks for tests * add setup step * fixes * add featurelist to auth api * grandfather state and typos * typo * merge new-eventstore * fix login policy tests * label policy in features * audit log retention
48 lines
1.1 KiB
Go
48 lines
1.1 KiB
Go
package command
|
|
|
|
import (
|
|
"github.com/caos/zitadel/internal/domain"
|
|
"github.com/caos/zitadel/internal/eventstore"
|
|
"github.com/caos/zitadel/internal/repository/policy"
|
|
)
|
|
|
|
type SecondFactorWriteModel struct {
|
|
eventstore.WriteModel
|
|
MFAType domain.SecondFactorType
|
|
State domain.FactorState
|
|
}
|
|
|
|
func (wm *SecondFactorWriteModel) Reduce() error {
|
|
for _, event := range wm.Events {
|
|
switch e := event.(type) {
|
|
case *policy.SecondFactorAddedEvent:
|
|
wm.MFAType = e.MFAType
|
|
wm.State = domain.FactorStateActive
|
|
case *policy.SecondFactorRemovedEvent:
|
|
wm.MFAType = e.MFAType
|
|
wm.State = domain.FactorStateRemoved
|
|
}
|
|
}
|
|
return wm.WriteModel.Reduce()
|
|
}
|
|
|
|
type MultiFactorWriteModel struct {
|
|
eventstore.WriteModel
|
|
MFAType domain.MultiFactorType
|
|
State domain.FactorState
|
|
}
|
|
|
|
func (wm *MultiFactorWriteModel) Reduce() error {
|
|
for _, event := range wm.Events {
|
|
switch e := event.(type) {
|
|
case *policy.MultiFactorAddedEvent:
|
|
wm.MFAType = e.MFAType
|
|
wm.State = domain.FactorStateActive
|
|
case *policy.MultiFactorRemovedEvent:
|
|
wm.MFAType = e.MFAType
|
|
wm.State = domain.FactorStateRemoved
|
|
}
|
|
}
|
|
return wm.WriteModel.Reduce()
|
|
}
|