mirror of
https://github.com/zitadel/zitadel.git
synced 2024-12-13 11:34:26 +00:00
75f1c4c576
* feat: add search user memberships * feat: add search user memberships * feat: read user member ship * feat: add usergrant search key * feat: uesrmemberships based on permissions * feat: merge master * fix: correct permissions * fix: update display name on change profile * fix: merge request converations * fix: err handling * Update internal/user/model/user_membership_view.go Co-authored-by: Silvan <silvan.reusser@gmail.com> Co-authored-by: Silvan <silvan.reusser@gmail.com>
89 lines
2.1 KiB
Go
89 lines
2.1 KiB
Go
package model
|
|
|
|
import (
|
|
"time"
|
|
|
|
"github.com/caos/zitadel/internal/model"
|
|
)
|
|
|
|
type UserMembershipView struct {
|
|
UserID string
|
|
MemberType MemberType
|
|
AggregateID string
|
|
//ObjectID differs from aggregate id if obejct is sub of an aggregate
|
|
ObjectID string
|
|
|
|
Roles []string
|
|
DisplayName string
|
|
CreationDate time.Time
|
|
ChangeDate time.Time
|
|
ResourceOwner string
|
|
Sequence uint64
|
|
}
|
|
|
|
type MemberType int32
|
|
|
|
const (
|
|
MemberTypeUnspecified MemberType = iota
|
|
MemberTypeOrganisation
|
|
MemberTypeProject
|
|
MemberTypeProjectGrant
|
|
)
|
|
|
|
type UserMembershipSearchRequest struct {
|
|
Offset uint64
|
|
Limit uint64
|
|
SortingColumn UserMembershipSearchKey
|
|
Asc bool
|
|
Queries []*UserMembershipSearchQuery
|
|
}
|
|
|
|
type UserMembershipSearchKey int32
|
|
|
|
const (
|
|
UserMembershipSearchKeyUnspecified UserMembershipSearchKey = iota
|
|
UserMembershipSearchKeyUserID
|
|
UserMembershipSearchKeyMemberType
|
|
UserMembershipSearchKeyAggregateID
|
|
UserMembershipSearchKeyObjectID
|
|
UserMembershipSearchKeyResourceOwner
|
|
)
|
|
|
|
type UserMembershipSearchQuery struct {
|
|
Key UserMembershipSearchKey
|
|
Method model.SearchMethod
|
|
Value interface{}
|
|
}
|
|
|
|
type UserMembershipSearchResponse struct {
|
|
Offset uint64
|
|
Limit uint64
|
|
TotalResult uint64
|
|
Result []*UserMembershipView
|
|
Sequence uint64
|
|
Timestamp time.Time
|
|
}
|
|
|
|
func (r *UserMembershipSearchRequest) EnsureLimit(limit uint64) {
|
|
if r.Limit == 0 || r.Limit > limit {
|
|
r.Limit = limit
|
|
}
|
|
}
|
|
|
|
func (r *UserMembershipSearchRequest) GetSearchQuery(key UserMembershipSearchKey) (int, *UserMembershipSearchQuery) {
|
|
for i, q := range r.Queries {
|
|
if q.Key == key {
|
|
return i, q
|
|
}
|
|
}
|
|
return -1, nil
|
|
}
|
|
|
|
func (r *UserMembershipSearchRequest) AppendResourceOwnerQuery(orgID string) {
|
|
r.Queries = append(r.Queries, &UserMembershipSearchQuery{Key: UserMembershipSearchKeyResourceOwner, Method: model.SearchMethodEquals, Value: orgID})
|
|
}
|
|
|
|
func (r *UserMembershipSearchRequest) AppendUserIDQuery(userID string) {
|
|
r.Queries = append(r.Queries, &UserMembershipSearchQuery{Key: UserMembershipSearchKeyUserID, Method: model.SearchMethodEquals, Value: userID})
|
|
}
|