mirror of
https://github.com/zitadel/zitadel.git
synced 2024-12-19 06:17:32 +00:00
bc951985ed
* feat: lock users if lockout policy is set * feat: setup * feat: lock user on password failes * feat: render error * feat: lock user on command side * feat: auth_req tests * feat: lockout policy docs * feat: remove show lockout failures from proto * fix: console lockout * feat: tests * fix: tests * unlock function * add unlock button * fix migration version * lockout policy * lint * Update internal/auth/repository/eventsourcing/eventstore/auth_request.go Co-authored-by: Silvan <silvan.reusser@gmail.com> * fix: err message * Update internal/command/setup_step4.go Co-authored-by: Silvan <silvan.reusser@gmail.com> Co-authored-by: Max Peintner <max@caos.ch> Co-authored-by: Livio Amstutz <livio.a@gmail.com> Co-authored-by: Silvan <silvan.reusser@gmail.com>
54 lines
1.7 KiB
Go
54 lines
1.7 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 (
|
|
lockoutPolicyTable = "management.lockout_policies"
|
|
)
|
|
|
|
func (v *View) LockoutPolicyByAggregateID(aggregateID string) (*model.LockoutPolicyView, error) {
|
|
return view.GetLockoutPolicyByAggregateID(v.Db, lockoutPolicyTable, aggregateID)
|
|
}
|
|
|
|
func (v *View) PutLockoutPolicy(policy *model.LockoutPolicyView, event *models.Event) error {
|
|
err := view.PutLockoutPolicy(v.Db, lockoutPolicyTable, 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, lockoutPolicyTable, aggregateID)
|
|
if err != nil && !errors.IsNotFound(err) {
|
|
return err
|
|
}
|
|
return v.ProcessedLockoutPolicySequence(event)
|
|
}
|
|
|
|
func (v *View) GetLatestLockoutPolicySequence() (*global_view.CurrentSequence, error) {
|
|
return v.latestSequence(lockoutPolicyTable)
|
|
}
|
|
|
|
func (v *View) ProcessedLockoutPolicySequence(event *models.Event) error {
|
|
return v.saveCurrentSequence(lockoutPolicyTable, event)
|
|
}
|
|
|
|
func (v *View) UpdateLockoutPolicySpoolerRunTimestamp() error {
|
|
return v.updateSpoolerRunSequence(lockoutPolicyTable)
|
|
}
|
|
|
|
func (v *View) GetLatestLockoutPolicyFailedEvent(sequence uint64) (*global_view.FailedEvent, error) {
|
|
return v.latestFailedEvent(lockoutPolicyTable, sequence)
|
|
}
|
|
|
|
func (v *View) ProcessedLockoutPolicyFailedEvent(failedEvent *global_view.FailedEvent) error {
|
|
return v.saveFailedEvent(failedEvent)
|
|
}
|