mirror of
https://github.com/zitadel/zitadel.git
synced 2024-12-13 11:34:26 +00:00
1dd82ab1b7
* Changes added * Reading of events for applications changed. * Proto changed * Tests added * Added more tests. * Struct for Data expanded with additional fields. * refactoring * Changes from review. * Merge in to Master * Changes from review. * fix: generate proto Co-authored-by: Fabiennne <fabienne.gerschwiler@gmail.com>
57 lines
1.1 KiB
Go
57 lines
1.1 KiB
Go
package model
|
|
|
|
import (
|
|
es_models "github.com/caos/zitadel/internal/eventstore/models"
|
|
"github.com/golang/protobuf/ptypes/timestamp"
|
|
)
|
|
|
|
type Org struct {
|
|
es_models.ObjectRoot
|
|
|
|
State OrgState
|
|
Name string
|
|
Domain string
|
|
|
|
Members []*OrgMember
|
|
}
|
|
type OrgChanges struct {
|
|
Changes []*OrgChange
|
|
LastSequence uint64
|
|
}
|
|
|
|
type OrgChange struct {
|
|
ChangeDate *timestamp.Timestamp `json:"changeDate,omitempty"`
|
|
EventType string `json:"eventType,omitempty"`
|
|
Sequence uint64 `json:"sequence,omitempty"`
|
|
Modifier string `json:"modifierUser,omitempty"`
|
|
Data interface{} `json:"data,omitempty"`
|
|
}
|
|
|
|
type OrgState int32
|
|
|
|
const (
|
|
ORGSTATE_ACTIVE OrgState = iota
|
|
ORGSTATE_INACTIVE
|
|
)
|
|
|
|
func NewOrg(id string) *Org {
|
|
return &Org{ObjectRoot: es_models.ObjectRoot{AggregateID: id}, State: ORGSTATE_ACTIVE}
|
|
}
|
|
|
|
func (o *Org) IsActive() bool {
|
|
return o.State == ORGSTATE_ACTIVE
|
|
}
|
|
|
|
func (o *Org) IsValid() bool {
|
|
return o.Name != "" && o.Domain != ""
|
|
}
|
|
|
|
func (o *Org) ContainsMember(userID string) bool {
|
|
for _, member := range o.Members {
|
|
if member.UserID == userID {
|
|
return true
|
|
}
|
|
}
|
|
return false
|
|
}
|