mirror of
https://github.com/zitadel/zitadel.git
synced 2025-04-30 17:21:23 +00:00

* feat: add hide password reset to login policy * feat: tests * feat: hide password reset in login * feat: hide password reset to frontend * feat: hide password reset to frontend * feat: hide password reset to frontend * feat: check feature * feat: feature in frontend
85 lines
2.1 KiB
Go
85 lines
2.1 KiB
Go
package iam
|
|
|
|
import (
|
|
"context"
|
|
"github.com/caos/zitadel/internal/eventstore"
|
|
|
|
"github.com/caos/zitadel/internal/domain"
|
|
"github.com/caos/zitadel/internal/eventstore/repository"
|
|
"github.com/caos/zitadel/internal/repository/policy"
|
|
)
|
|
|
|
var (
|
|
LoginPolicyAddedEventType = iamEventTypePrefix + policy.LoginPolicyAddedEventType
|
|
LoginPolicyChangedEventType = iamEventTypePrefix + policy.LoginPolicyChangedEventType
|
|
)
|
|
|
|
type LoginPolicyAddedEvent struct {
|
|
policy.LoginPolicyAddedEvent
|
|
}
|
|
|
|
func NewLoginPolicyAddedEvent(
|
|
ctx context.Context,
|
|
aggregate *eventstore.Aggregate,
|
|
allowUsernamePassword,
|
|
allowRegister,
|
|
allowExternalIDP,
|
|
forceMFA,
|
|
hidePasswordReset bool,
|
|
passwordlessType domain.PasswordlessType,
|
|
) *LoginPolicyAddedEvent {
|
|
return &LoginPolicyAddedEvent{
|
|
LoginPolicyAddedEvent: *policy.NewLoginPolicyAddedEvent(
|
|
eventstore.NewBaseEventForPush(
|
|
ctx,
|
|
aggregate,
|
|
LoginPolicyAddedEventType),
|
|
allowUsernamePassword,
|
|
allowRegister,
|
|
allowExternalIDP,
|
|
forceMFA,
|
|
hidePasswordReset,
|
|
passwordlessType),
|
|
}
|
|
}
|
|
|
|
func LoginPolicyAddedEventMapper(event *repository.Event) (eventstore.EventReader, error) {
|
|
e, err := policy.LoginPolicyAddedEventMapper(event)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return &LoginPolicyAddedEvent{LoginPolicyAddedEvent: *e.(*policy.LoginPolicyAddedEvent)}, nil
|
|
}
|
|
|
|
type LoginPolicyChangedEvent struct {
|
|
policy.LoginPolicyChangedEvent
|
|
}
|
|
|
|
func NewLoginPolicyChangedEvent(
|
|
ctx context.Context,
|
|
aggregate *eventstore.Aggregate,
|
|
changes []policy.LoginPolicyChanges,
|
|
) (*LoginPolicyChangedEvent, error) {
|
|
changedEvent, err := policy.NewLoginPolicyChangedEvent(
|
|
eventstore.NewBaseEventForPush(
|
|
ctx,
|
|
aggregate,
|
|
LoginPolicyChangedEventType),
|
|
changes,
|
|
)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return &LoginPolicyChangedEvent{LoginPolicyChangedEvent: *changedEvent}, nil
|
|
}
|
|
|
|
func LoginPolicyChangedEventMapper(event *repository.Event) (eventstore.EventReader, error) {
|
|
e, err := policy.LoginPolicyChangedEventMapper(event)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return &LoginPolicyChangedEvent{LoginPolicyChangedEvent: *e.(*policy.LoginPolicyChangedEvent)}, nil
|
|
}
|