mirror of
https://github.com/zitadel/zitadel.git
synced 2024-12-12 19:14:23 +00:00
54 lines
1.8 KiB
Go
54 lines
1.8 KiB
Go
|
package view
|
||
|
|
||
|
import (
|
||
|
"github.com/caos/zitadel/internal/errors"
|
||
|
"github.com/caos/zitadel/internal/eventstore/v1/models"
|
||
|
"github.com/caos/zitadel/internal/iam/repository/view"
|
||
|
"github.com/caos/zitadel/internal/iam/repository/view/model"
|
||
|
global_view "github.com/caos/zitadel/internal/view/repository"
|
||
|
)
|
||
|
|
||
|
const (
|
||
|
passwordLockoutPolicyTable = "auth.lockout_policies"
|
||
|
)
|
||
|
|
||
|
func (v *View) LockoutPolicyByAggregateID(aggregateID string) (*model.LockoutPolicyView, error) {
|
||
|
return view.GetLockoutPolicyByAggregateID(v.Db, passwordLockoutPolicyTable, aggregateID)
|
||
|
}
|
||
|
|
||
|
func (v *View) PutLockoutPolicy(policy *model.LockoutPolicyView, event *models.Event) error {
|
||
|
err := view.PutLockoutPolicy(v.Db, passwordLockoutPolicyTable, policy)
|
||
|
if err != nil {
|
||
|
return err
|
||
|
}
|
||
|
return v.ProcessedLockoutPolicySequence(event)
|
||
|
}
|
||
|
|
||
|
func (v *View) DeleteLockoutPolicy(aggregateID string, event *models.Event) error {
|
||
|
err := view.DeleteLockoutPolicy(v.Db, passwordLockoutPolicyTable, aggregateID)
|
||
|
if err != nil && !errors.IsNotFound(err) {
|
||
|
return err
|
||
|
}
|
||
|
return v.ProcessedLockoutPolicySequence(event)
|
||
|
}
|
||
|
|
||
|
func (v *View) GetLatestLockoutPolicySequence() (*global_view.CurrentSequence, error) {
|
||
|
return v.latestSequence(passwordLockoutPolicyTable)
|
||
|
}
|
||
|
|
||
|
func (v *View) ProcessedLockoutPolicySequence(event *models.Event) error {
|
||
|
return v.saveCurrentSequence(passwordLockoutPolicyTable, event)
|
||
|
}
|
||
|
|
||
|
func (v *View) UpdateLockoutPolicySpoolerRunTimestamp() error {
|
||
|
return v.updateSpoolerRunSequence(passwordLockoutPolicyTable)
|
||
|
}
|
||
|
|
||
|
func (v *View) GetLatestLockoutPolicyFailedEvent(sequence uint64) (*global_view.FailedEvent, error) {
|
||
|
return v.latestFailedEvent(passwordLockoutPolicyTable, sequence)
|
||
|
}
|
||
|
|
||
|
func (v *View) ProcessedLockoutPolicyFailedEvent(failedEvent *global_view.FailedEvent) error {
|
||
|
return v.saveFailedEvent(failedEvent)
|
||
|
}
|