fix(iam_member): naming, error handling, column name (#355)

This commit is contained in:
Silvan 2020-07-07 11:42:39 +02:00 committed by GitHub
parent 9c277e2efb
commit 18669b39c1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 8 deletions

View File

@ -1,6 +1,7 @@
package view
import (
"github.com/caos/zitadel/internal/errors"
iam_model "github.com/caos/zitadel/internal/iam/model"
"github.com/caos/zitadel/internal/iam/repository/view"
"github.com/caos/zitadel/internal/iam/repository/view/model"
@ -31,10 +32,10 @@ func (v *View) PutIamMember(org *model.IamMemberView, sequence uint64) error {
return v.ProcessedIamMemberSequence(sequence)
}
func (v *View) DeleteIamMember(orgID, userID string, eventSequence uint64) error {
err := view.DeleteIamMember(v.Db, iamMemberTable, orgID, userID)
if err != nil {
return nil
func (v *View) DeleteIamMember(iamID, userID string, eventSequence uint64) error {
err := view.DeleteIamMember(v.Db, iamMemberTable, iamID, userID)
if err != nil && !errors.IsNotFound(err) {
return err
}
return v.ProcessedIamMemberSequence(eventSequence)
}

View File

@ -12,9 +12,9 @@ import (
func IamMemberByIDs(db *gorm.DB, table, orgID, userID string) (*model.IamMemberView, error) {
member := new(model.IamMemberView)
orgIDQuery := &model.IamMemberSearchQuery{Key: iam_model.IamMemberSearchKeyIamID, Value: orgID, Method: global_model.SearchMethodEquals}
iamIDQuery := &model.IamMemberSearchQuery{Key: iam_model.IamMemberSearchKeyIamID, Value: orgID, Method: global_model.SearchMethodEquals}
userIDQuery := &model.IamMemberSearchQuery{Key: iam_model.IamMemberSearchKeyUserID, Value: userID, Method: global_model.SearchMethodEquals}
query := repository.PrepareGetByQuery(table, orgIDQuery, userIDQuery)
query := repository.PrepareGetByQuery(table, iamIDQuery, userIDQuery)
err := query(db, member)
if caos_errs.IsNotFound(err) {
return nil, caos_errs.ThrowNotFound(nil, "VIEW-Ahq2s", "Errors.Iam.MemberNotExisting")

View File

@ -2,9 +2,10 @@ package model
import (
"encoding/json"
es_model "github.com/caos/zitadel/internal/iam/repository/eventsourcing/model"
"time"
es_model "github.com/caos/zitadel/internal/iam/repository/eventsourcing/model"
"github.com/caos/logging"
caos_errs "github.com/caos/zitadel/internal/errors"
"github.com/caos/zitadel/internal/eventstore/models"
@ -14,7 +15,7 @@ import (
const (
IamMemberKeyUserID = "user_id"
IamMemberKeyIamID = "org_id"
IamMemberKeyIamID = "iam_id"
IamMemberKeyUserName = "user_name"
IamMemberKeyEmail = "email"
IamMemberKeyFirstName = "first_name"