mirror of
https://github.com/zitadel/zitadel.git
synced 2024-12-13 19:44:21 +00:00
fix: handle password data correct on user creation (#6515)
This commit is contained in:
parent
54dab24a1a
commit
62d679e553
@ -3,7 +3,6 @@ package command
|
|||||||
import (
|
import (
|
||||||
"golang.org/x/text/language"
|
"golang.org/x/text/language"
|
||||||
|
|
||||||
"github.com/zitadel/zitadel/internal/crypto"
|
|
||||||
"github.com/zitadel/zitadel/internal/domain"
|
"github.com/zitadel/zitadel/internal/domain"
|
||||||
"github.com/zitadel/zitadel/internal/eventstore"
|
"github.com/zitadel/zitadel/internal/eventstore"
|
||||||
"github.com/zitadel/zitadel/internal/repository/user"
|
"github.com/zitadel/zitadel/internal/repository/user"
|
||||||
@ -34,9 +33,6 @@ type HumanWriteModel struct {
|
|||||||
Region string
|
Region string
|
||||||
StreetAddress string
|
StreetAddress string
|
||||||
|
|
||||||
Secret *crypto.CryptoValue
|
|
||||||
SecretChangeRequired bool
|
|
||||||
|
|
||||||
UserState domain.UserState
|
UserState domain.UserState
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -74,8 +70,6 @@ func (wm *HumanWriteModel) Reduce() error {
|
|||||||
wm.reduceHumanPhoneVerifiedEvent()
|
wm.reduceHumanPhoneVerifiedEvent()
|
||||||
case *user.HumanPhoneRemovedEvent:
|
case *user.HumanPhoneRemovedEvent:
|
||||||
wm.reduceHumanPhoneRemovedEvent()
|
wm.reduceHumanPhoneRemovedEvent()
|
||||||
case *user.HumanPasswordChangedEvent:
|
|
||||||
wm.reduceHumanPasswordChangedEvent(e)
|
|
||||||
case *user.HumanAvatarAddedEvent:
|
case *user.HumanAvatarAddedEvent:
|
||||||
wm.Avatar = e.StoreKey
|
wm.Avatar = e.StoreKey
|
||||||
case *user.HumanAvatarRemovedEvent:
|
case *user.HumanAvatarRemovedEvent:
|
||||||
@ -123,7 +117,6 @@ func (wm *HumanWriteModel) Query() *eventstore.SearchQueryBuilder {
|
|||||||
user.HumanPhoneRemovedType,
|
user.HumanPhoneRemovedType,
|
||||||
user.HumanAvatarAddedType,
|
user.HumanAvatarAddedType,
|
||||||
user.HumanAvatarRemovedType,
|
user.HumanAvatarRemovedType,
|
||||||
user.HumanPasswordChangedType,
|
|
||||||
user.UserLockedType,
|
user.UserLockedType,
|
||||||
user.UserUnlockedType,
|
user.UserUnlockedType,
|
||||||
user.UserDeactivatedType,
|
user.UserDeactivatedType,
|
||||||
@ -138,8 +131,7 @@ func (wm *HumanWriteModel) Query() *eventstore.SearchQueryBuilder {
|
|||||||
user.UserV1EmailVerifiedType,
|
user.UserV1EmailVerifiedType,
|
||||||
user.UserV1PhoneChangedType,
|
user.UserV1PhoneChangedType,
|
||||||
user.UserV1PhoneVerifiedType,
|
user.UserV1PhoneVerifiedType,
|
||||||
user.UserV1PhoneRemovedType,
|
user.UserV1PhoneRemovedType).
|
||||||
user.UserV1PasswordChangedType).
|
|
||||||
Builder()
|
Builder()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -158,8 +150,6 @@ func (wm *HumanWriteModel) reduceHumanAddedEvent(e *user.HumanAddedEvent) {
|
|||||||
wm.PostalCode = e.PostalCode
|
wm.PostalCode = e.PostalCode
|
||||||
wm.Region = e.Region
|
wm.Region = e.Region
|
||||||
wm.StreetAddress = e.StreetAddress
|
wm.StreetAddress = e.StreetAddress
|
||||||
wm.Secret = e.Secret
|
|
||||||
wm.SecretChangeRequired = e.ChangeRequired
|
|
||||||
wm.UserState = domain.UserStateActive
|
wm.UserState = domain.UserStateActive
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -178,8 +168,6 @@ func (wm *HumanWriteModel) reduceHumanRegisteredEvent(e *user.HumanRegisteredEve
|
|||||||
wm.PostalCode = e.PostalCode
|
wm.PostalCode = e.PostalCode
|
||||||
wm.Region = e.Region
|
wm.Region = e.Region
|
||||||
wm.StreetAddress = e.StreetAddress
|
wm.StreetAddress = e.StreetAddress
|
||||||
wm.Secret = e.Secret
|
|
||||||
wm.SecretChangeRequired = e.ChangeRequired
|
|
||||||
wm.UserState = domain.UserStateActive
|
wm.UserState = domain.UserStateActive
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -244,8 +232,3 @@ func (wm *HumanWriteModel) reduceHumanAddressChangedEvent(e *user.HumanAddressCh
|
|||||||
wm.StreetAddress = *e.StreetAddress
|
wm.StreetAddress = *e.StreetAddress
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (wm *HumanWriteModel) reduceHumanPasswordChangedEvent(e *user.HumanPasswordChangedEvent) {
|
|
||||||
wm.Secret = e.Secret
|
|
||||||
wm.SecretChangeRequired = e.ChangeRequired
|
|
||||||
}
|
|
||||||
|
@ -13,7 +13,6 @@ import (
|
|||||||
"github.com/zitadel/zitadel/internal/api/call"
|
"github.com/zitadel/zitadel/internal/api/call"
|
||||||
"github.com/zitadel/zitadel/internal/eventstore"
|
"github.com/zitadel/zitadel/internal/eventstore"
|
||||||
"github.com/zitadel/zitadel/internal/repository/pseudo"
|
"github.com/zitadel/zitadel/internal/repository/pseudo"
|
||||||
"github.com/zitadel/zitadel/internal/telemetry/tracing"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@ -142,9 +141,6 @@ func (h *ProjectionHandler) Trigger(ctx context.Context, instances ...string) co
|
|||||||
// If a bulk action was executed, the call timestamp in context will be reset for subsequent queries.
|
// If a bulk action was executed, the call timestamp in context will be reset for subsequent queries.
|
||||||
// The returned context is never nil. It is either the original context or an updated context.
|
// The returned context is never nil. It is either the original context or an updated context.
|
||||||
func (h *ProjectionHandler) TriggerErr(ctx context.Context, instances ...string) (outCtx context.Context, err error) {
|
func (h *ProjectionHandler) TriggerErr(ctx context.Context, instances ...string) (outCtx context.Context, err error) {
|
||||||
ctx, span := tracing.NewSpan(ctx)
|
|
||||||
defer span.EndWithError(err)
|
|
||||||
|
|
||||||
instances = triggerInstances(ctx, instances)
|
instances = triggerInstances(ctx, instances)
|
||||||
defer func() {
|
defer func() {
|
||||||
outCtx = call.ResetTimestamp(ctx)
|
outCtx = call.ResetTimestamp(ctx)
|
||||||
|
@ -352,7 +352,7 @@ func (p *userProjection) reduceHumanAdded(event eventstore.Event) (*handler.Stat
|
|||||||
handler.NewCol(NotifyInstanceIDCol, e.Aggregate().InstanceID),
|
handler.NewCol(NotifyInstanceIDCol, e.Aggregate().InstanceID),
|
||||||
handler.NewCol(NotifyLastEmailCol, e.EmailAddress),
|
handler.NewCol(NotifyLastEmailCol, e.EmailAddress),
|
||||||
handler.NewCol(NotifyLastPhoneCol, &sql.NullString{String: string(e.PhoneNumber), Valid: e.PhoneNumber != ""}),
|
handler.NewCol(NotifyLastPhoneCol, &sql.NullString{String: string(e.PhoneNumber), Valid: e.PhoneNumber != ""}),
|
||||||
handler.NewCol(NotifyPasswordSetCol, e.Secret != nil),
|
handler.NewCol(NotifyPasswordSetCol, user.SecretOrEncodedHash(e.Secret, e.EncodedHash) != ""),
|
||||||
},
|
},
|
||||||
crdb.WithTableSuffix(UserNotifySuffix),
|
crdb.WithTableSuffix(UserNotifySuffix),
|
||||||
),
|
),
|
||||||
@ -400,7 +400,7 @@ func (p *userProjection) reduceHumanRegistered(event eventstore.Event) (*handler
|
|||||||
handler.NewCol(NotifyInstanceIDCol, e.Aggregate().InstanceID),
|
handler.NewCol(NotifyInstanceIDCol, e.Aggregate().InstanceID),
|
||||||
handler.NewCol(NotifyLastEmailCol, e.EmailAddress),
|
handler.NewCol(NotifyLastEmailCol, e.EmailAddress),
|
||||||
handler.NewCol(NotifyLastPhoneCol, &sql.NullString{String: string(e.PhoneNumber), Valid: e.PhoneNumber != ""}),
|
handler.NewCol(NotifyLastPhoneCol, &sql.NullString{String: string(e.PhoneNumber), Valid: e.PhoneNumber != ""}),
|
||||||
handler.NewCol(NotifyPasswordSetCol, e.Secret != nil),
|
handler.NewCol(NotifyPasswordSetCol, user.SecretOrEncodedHash(e.Secret, e.EncodedHash) != ""),
|
||||||
},
|
},
|
||||||
crdb.WithTableSuffix(UserNotifySuffix),
|
crdb.WithTableSuffix(UserNotifySuffix),
|
||||||
),
|
),
|
||||||
|
Loading…
Reference in New Issue
Block a user