zitadel/internal/user/model/user_view.go
Fabi 7a6ca24625
feat: multiple domains (#188)
* check uniqueness on create and register user

* change user email, reserve release unique email

* usergrant unique aggregate

* usergrant uniqueness

* validate UserGrant

* fix tests

* domain is set on username in all orgs

* domain in admin

* org domain sql

* zitadel domain org name

* org domains

* org iam policy

* default org iam policy

* SETUP

* load login names

* login by login name

* login name

* fix: merge master

* fix: merge master

* Update internal/user/repository/eventsourcing/user.go

Co-authored-by: Livio Amstutz <livio.a@gmail.com>

* fix: fix unique domains

* fix: rename env variable

Co-authored-by: adlerhurst <silvan.reusser@gmail.com>
Co-authored-by: Livio Amstutz <livio.a@gmail.com>
2020-06-16 11:40:18 +02:00

124 lines
2.9 KiB
Go

package model
import (
"time"
req_model "github.com/caos/zitadel/internal/auth_request/model"
"github.com/caos/zitadel/internal/model"
)
type UserView struct {
ID string
CreationDate time.Time
ChangeDate time.Time
State UserState
ResourceOwner string
PasswordSet bool
PasswordChangeRequired bool
PasswordChanged time.Time
LastLogin time.Time
UserName string
LoginNames []string
FirstName string
LastName string
NickName string
DisplayName string
PreferredLanguage string
Gender Gender
Email string
IsEmailVerified bool
Phone string
IsPhoneVerified bool
Country string
Locality string
PostalCode string
Region string
StreetAddress string
OTPState MfaState
MfaMaxSetUp req_model.MfaLevel
MfaInitSkipped time.Time
InitRequired bool
Sequence uint64
}
type UserSearchRequest struct {
Offset uint64
Limit uint64
SortingColumn UserSearchKey
Asc bool
Queries []*UserSearchQuery
}
type UserSearchKey int32
const (
USERSEARCHKEY_UNSPECIFIED UserSearchKey = iota
USERSEARCHKEY_USER_ID
USERSEARCHKEY_USER_NAME
USERSEARCHKEY_FIRST_NAME
USERSEARCHKEY_LAST_NAME
USERSEARCHKEY_NICK_NAME
USERSEARCHKEY_DISPLAY_NAME
USERSEARCHKEY_EMAIL
USERSEARCHKEY_STATE
USERSEARCHKEY_RESOURCEOWNER
USERSEARCHKEY_LOGIN_NAMES
)
type UserSearchQuery struct {
Key UserSearchKey
Method model.SearchMethod
Value interface{}
}
type UserSearchResponse struct {
Offset uint64
Limit uint64
TotalResult uint64
Result []*UserView
}
func (r *UserSearchRequest) EnsureLimit(limit uint64) {
if r.Limit == 0 || r.Limit > limit {
r.Limit = limit
}
}
func (r *UserSearchRequest) AppendMyOrgQuery(orgID string) {
r.Queries = append(r.Queries, &UserSearchQuery{Key: USERSEARCHKEY_RESOURCEOWNER, Method: model.SEARCHMETHOD_EQUALS, Value: orgID})
}
func (u *UserView) MfaTypesSetupPossible(level req_model.MfaLevel) []req_model.MfaType {
types := make([]req_model.MfaType, 0)
switch level {
default:
fallthrough
case req_model.MfaLevelSoftware:
if u.OTPState != MFASTATE_READY {
types = append(types, req_model.MfaTypeOTP)
}
//PLANNED: add sms
fallthrough
case req_model.MfaLevelHardware:
//PLANNED: add token
}
return types
}
func (u *UserView) MfaTypesAllowed(level req_model.MfaLevel) []req_model.MfaType {
types := make([]req_model.MfaType, 0)
switch level {
default:
fallthrough
case req_model.MfaLevelSoftware:
if u.OTPState == MFASTATE_READY {
types = append(types, req_model.MfaTypeOTP)
}
//PLANNED: add sms
fallthrough
case req_model.MfaLevelHardware:
//PLANNED: add token
}
return types
}