2021-01-05 08:33:45 +00:00
|
|
|
package domain
|
|
|
|
|
|
|
|
import (
|
2022-04-26 23:01:45 +00:00
|
|
|
es_models "github.com/zitadel/zitadel/internal/eventstore/v1/models"
|
2021-01-05 08:33:45 +00:00
|
|
|
)
|
|
|
|
|
2021-01-08 10:33:45 +00:00
|
|
|
type Member struct {
|
2021-01-05 08:33:45 +00:00
|
|
|
es_models.ObjectRoot
|
|
|
|
|
|
|
|
UserID string
|
|
|
|
Roles []string
|
|
|
|
}
|
|
|
|
|
2021-01-08 10:33:45 +00:00
|
|
|
func NewMember(aggregateID, userID string, roles ...string) *Member {
|
|
|
|
return &Member{
|
|
|
|
ObjectRoot: es_models.ObjectRoot{
|
|
|
|
AggregateID: aggregateID,
|
|
|
|
},
|
|
|
|
UserID: userID,
|
|
|
|
Roles: roles,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (i *Member) IsValid() bool {
|
2021-01-05 08:33:45 +00:00
|
|
|
return i.AggregateID != "" && i.UserID != "" && len(i.Roles) != 0
|
|
|
|
}
|
2021-01-07 15:06:45 +00:00
|
|
|
|
2021-03-15 11:51:15 +00:00
|
|
|
func (i *Member) IsIAMValid() bool {
|
|
|
|
return i.UserID != "" && len(i.Roles) != 0
|
|
|
|
}
|
|
|
|
|
2021-01-07 15:06:45 +00:00
|
|
|
type MemberState int32
|
|
|
|
|
|
|
|
const (
|
|
|
|
MemberStateUnspecified MemberState = iota
|
|
|
|
MemberStateActive
|
|
|
|
MemberStateRemoved
|
|
|
|
|
|
|
|
memberStateCount
|
|
|
|
)
|
|
|
|
|
|
|
|
func (f MemberState) Valid() bool {
|
|
|
|
return f >= 0 && f < memberStateCount
|
|
|
|
}
|