mirror of
https://github.com/zitadel/zitadel.git
synced 2025-01-12 04:13:40 +00:00
dc56e298ae
* fix: use domain models for v2 eventstore * fix: user domain model * Update internal/api/grpc/admin/login_policy_converter.go Co-authored-by: Livio Amstutz <livio.a@gmail.com> * fix: converter Co-authored-by: Livio Amstutz <livio.a@gmail.com>
41 lines
649 B
Go
41 lines
649 B
Go
package domain
|
|
|
|
import es_models "github.com/caos/zitadel/internal/eventstore/models"
|
|
|
|
type User struct {
|
|
es_models.ObjectRoot
|
|
State UserState
|
|
UserName string
|
|
|
|
*Human
|
|
*Machine
|
|
}
|
|
|
|
type UserState int32
|
|
|
|
const (
|
|
UserStateUnspecified UserState = iota
|
|
UserStateActive
|
|
UserStateInactive
|
|
UserStateDeleted
|
|
UserStateLocked
|
|
UserStateSuspend
|
|
UserStateInitial
|
|
|
|
userStateCount
|
|
)
|
|
|
|
func (f UserState) Valid() bool {
|
|
return f >= 0 && f < userStateCount
|
|
}
|
|
|
|
func (u *User) IsValid() bool {
|
|
if u.Human == nil && u.Machine == nil || u.UserName == "" {
|
|
return false
|
|
}
|
|
if u.Human != nil {
|
|
return u.Human.IsValid()
|
|
}
|
|
return u.Machine.IsValid()
|
|
}
|