mirror of
https://github.com/zitadel/zitadel.git
synced 2024-12-13 03:24:26 +00:00
fa9f581d56
* chore: move to new org * logging * fix: org rename caos -> zitadel Co-authored-by: adlerhurst <silvan.reusser@gmail.com>
82 lines
3.0 KiB
Go
82 lines
3.0 KiB
Go
package view
|
|
|
|
import (
|
|
"github.com/zitadel/zitadel/internal/errors"
|
|
"github.com/zitadel/zitadel/internal/eventstore/v1/models"
|
|
"github.com/zitadel/zitadel/internal/user/repository/view"
|
|
"github.com/zitadel/zitadel/internal/user/repository/view/model"
|
|
global_view "github.com/zitadel/zitadel/internal/view/repository"
|
|
)
|
|
|
|
const (
|
|
externalIDPTable = "auth.user_external_idps"
|
|
)
|
|
|
|
func (v *View) ExternalIDPByExternalUserIDAndIDPConfigID(externalUserID, idpConfigID, instanceID string) (*model.ExternalIDPView, error) {
|
|
return view.ExternalIDPByExternalUserIDAndIDPConfigID(v.Db, externalIDPTable, externalUserID, idpConfigID, instanceID)
|
|
}
|
|
|
|
func (v *View) ExternalIDPByExternalUserIDAndIDPConfigIDAndResourceOwner(externalUserID, idpConfigID, resourceOwner, instanceID string) (*model.ExternalIDPView, error) {
|
|
return view.ExternalIDPByExternalUserIDAndIDPConfigIDAndResourceOwner(v.Db, externalIDPTable, externalUserID, idpConfigID, resourceOwner, instanceID)
|
|
}
|
|
|
|
func (v *View) ExternalIDPsByIDPConfigID(idpConfigID, instanceID string) ([]*model.ExternalIDPView, error) {
|
|
return view.ExternalIDPsByIDPConfigID(v.Db, externalIDPTable, idpConfigID, instanceID)
|
|
}
|
|
|
|
func (v *View) PutExternalIDP(externalIDP *model.ExternalIDPView, event *models.Event) error {
|
|
err := view.PutExternalIDP(v.Db, externalIDPTable, externalIDP)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
return v.ProcessedExternalIDPSequence(event)
|
|
}
|
|
|
|
func (v *View) PutExternalIDPs(event *models.Event, externalIDPs ...*model.ExternalIDPView) error {
|
|
err := view.PutExternalIDPs(v.Db, externalIDPTable, externalIDPs...)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
return v.ProcessedExternalIDPSequence(event)
|
|
}
|
|
|
|
func (v *View) DeleteExternalIDP(externalUserID, idpConfigID, instanceID string, event *models.Event) error {
|
|
err := view.DeleteExternalIDP(v.Db, externalIDPTable, externalUserID, idpConfigID, instanceID)
|
|
if err != nil && !errors.IsNotFound(err) {
|
|
return err
|
|
}
|
|
return v.ProcessedExternalIDPSequence(event)
|
|
}
|
|
|
|
func (v *View) DeleteExternalIDPsByUserID(userID, instanceID string, event *models.Event) error {
|
|
err := view.DeleteExternalIDPsByUserID(v.Db, externalIDPTable, userID, instanceID)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
return v.ProcessedExternalIDPSequence(event)
|
|
}
|
|
|
|
func (v *View) GetLatestExternalIDPSequence(instanceID string) (*global_view.CurrentSequence, error) {
|
|
return v.latestSequence(externalIDPTable, instanceID)
|
|
}
|
|
|
|
func (v *View) GetLatestExternalIDPSequences() ([]*global_view.CurrentSequence, error) {
|
|
return v.latestSequences(externalIDPTable)
|
|
}
|
|
|
|
func (v *View) ProcessedExternalIDPSequence(event *models.Event) error {
|
|
return v.saveCurrentSequence(externalIDPTable, event)
|
|
}
|
|
|
|
func (v *View) UpdateExternalIDPSpoolerRunTimestamp() error {
|
|
return v.updateSpoolerRunSequence(externalIDPTable)
|
|
}
|
|
|
|
func (v *View) GetLatestExternalIDPFailedEvent(sequence uint64, instanceID string) (*global_view.FailedEvent, error) {
|
|
return v.latestFailedEvent(externalIDPTable, instanceID, sequence)
|
|
}
|
|
|
|
func (v *View) ProcessedExternalIDPFailedEvent(failedEvent *global_view.FailedEvent) error {
|
|
return v.saveFailedEvent(failedEvent)
|
|
}
|