mirror of
https://github.com/zitadel/zitadel.git
synced 2024-12-15 12:27:59 +00:00
5fdad7b8f4
# Which Problems Are Solved Users are not yet able to update their information an status in user API v3. # How the Problems Are Solved Add endpoints and functionality to update users and their status in user API v3. # Additional Changes Aggregate_type and event_types are updated with "userschema" to avoid conflicts with old events. # Additional Context closes #7898
174 lines
4.1 KiB
Go
174 lines
4.1 KiB
Go
package schemauser
|
|
|
|
import (
|
|
"context"
|
|
"time"
|
|
|
|
"github.com/zitadel/zitadel/internal/api/http"
|
|
"github.com/zitadel/zitadel/internal/crypto"
|
|
"github.com/zitadel/zitadel/internal/domain"
|
|
"github.com/zitadel/zitadel/internal/eventstore"
|
|
)
|
|
|
|
const (
|
|
phoneEventPrefix = eventPrefix + "phone."
|
|
PhoneUpdatedType = phoneEventPrefix + "updated"
|
|
PhoneVerifiedType = phoneEventPrefix + "verified"
|
|
PhoneVerificationFailedType = phoneEventPrefix + "verification.failed"
|
|
PhoneCodeAddedType = phoneEventPrefix + "code.added"
|
|
PhoneCodeSentType = phoneEventPrefix + "code.sent"
|
|
)
|
|
|
|
type PhoneUpdatedEvent struct {
|
|
*eventstore.BaseEvent `json:"-"`
|
|
|
|
PhoneNumber domain.PhoneNumber `json:"phone,omitempty"`
|
|
}
|
|
|
|
func (e *PhoneUpdatedEvent) SetBaseEvent(event *eventstore.BaseEvent) {
|
|
e.BaseEvent = event
|
|
}
|
|
|
|
func (e *PhoneUpdatedEvent) Payload() interface{} {
|
|
return e
|
|
}
|
|
|
|
func (e *PhoneUpdatedEvent) UniqueConstraints() []*eventstore.UniqueConstraint {
|
|
return nil
|
|
}
|
|
|
|
func NewPhoneUpdatedEvent(ctx context.Context, aggregate *eventstore.Aggregate, phone domain.PhoneNumber) *PhoneUpdatedEvent {
|
|
return &PhoneUpdatedEvent{
|
|
BaseEvent: eventstore.NewBaseEventForPush(
|
|
ctx,
|
|
aggregate,
|
|
PhoneUpdatedType,
|
|
),
|
|
PhoneNumber: phone,
|
|
}
|
|
}
|
|
|
|
type PhoneVerifiedEvent struct {
|
|
*eventstore.BaseEvent `json:"-"`
|
|
|
|
IsPhoneVerified bool `json:"-"`
|
|
}
|
|
|
|
func (e *PhoneVerifiedEvent) SetBaseEvent(event *eventstore.BaseEvent) {
|
|
e.BaseEvent = event
|
|
}
|
|
func (e *PhoneVerifiedEvent) Payload() interface{} {
|
|
return nil
|
|
}
|
|
|
|
func (e *PhoneVerifiedEvent) UniqueConstraints() []*eventstore.UniqueConstraint {
|
|
return nil
|
|
}
|
|
|
|
func NewPhoneVerifiedEvent(ctx context.Context, aggregate *eventstore.Aggregate) *PhoneVerifiedEvent {
|
|
return &PhoneVerifiedEvent{
|
|
BaseEvent: eventstore.NewBaseEventForPush(
|
|
ctx,
|
|
aggregate,
|
|
PhoneVerifiedType,
|
|
),
|
|
}
|
|
}
|
|
|
|
type PhoneVerificationFailedEvent struct {
|
|
*eventstore.BaseEvent `json:"-"`
|
|
}
|
|
|
|
func (e *PhoneVerificationFailedEvent) SetBaseEvent(event *eventstore.BaseEvent) {
|
|
e.BaseEvent = event
|
|
}
|
|
|
|
func (e *PhoneVerificationFailedEvent) Payload() interface{} {
|
|
return nil
|
|
}
|
|
|
|
func (e *PhoneVerificationFailedEvent) UniqueConstraints() []*eventstore.UniqueConstraint {
|
|
return nil
|
|
}
|
|
|
|
func NewPhoneVerificationFailedEvent(ctx context.Context, aggregate *eventstore.Aggregate) *PhoneVerificationFailedEvent {
|
|
return &PhoneVerificationFailedEvent{
|
|
BaseEvent: eventstore.NewBaseEventForPush(
|
|
ctx,
|
|
aggregate,
|
|
PhoneVerificationFailedType,
|
|
),
|
|
}
|
|
}
|
|
|
|
type PhoneCodeAddedEvent struct {
|
|
*eventstore.BaseEvent `json:"-"`
|
|
|
|
Code *crypto.CryptoValue `json:"code,omitempty"`
|
|
Expiry time.Duration `json:"expiry,omitempty"`
|
|
CodeReturned bool `json:"code_returned,omitempty"`
|
|
TriggeredAtOrigin string `json:"triggerOrigin,omitempty"`
|
|
}
|
|
|
|
func (e *PhoneCodeAddedEvent) Payload() interface{} {
|
|
return e
|
|
}
|
|
|
|
func (e *PhoneCodeAddedEvent) UniqueConstraints() []*eventstore.UniqueConstraint {
|
|
return nil
|
|
}
|
|
|
|
func (e *PhoneCodeAddedEvent) TriggerOrigin() string {
|
|
return e.TriggeredAtOrigin
|
|
}
|
|
|
|
func (e *PhoneCodeAddedEvent) SetBaseEvent(event *eventstore.BaseEvent) {
|
|
e.BaseEvent = event
|
|
}
|
|
|
|
func NewPhoneCodeAddedEvent(
|
|
ctx context.Context,
|
|
aggregate *eventstore.Aggregate,
|
|
code *crypto.CryptoValue,
|
|
expiry time.Duration,
|
|
codeReturned bool,
|
|
) *PhoneCodeAddedEvent {
|
|
return &PhoneCodeAddedEvent{
|
|
BaseEvent: eventstore.NewBaseEventForPush(
|
|
ctx,
|
|
aggregate,
|
|
PhoneCodeAddedType,
|
|
),
|
|
Code: code,
|
|
Expiry: expiry,
|
|
CodeReturned: codeReturned,
|
|
TriggeredAtOrigin: http.DomainContext(ctx).Origin(),
|
|
}
|
|
}
|
|
|
|
type PhoneCodeSentEvent struct {
|
|
*eventstore.BaseEvent `json:"-"`
|
|
}
|
|
|
|
func (e *PhoneCodeSentEvent) Payload() interface{} {
|
|
return e
|
|
}
|
|
|
|
func (e *PhoneCodeSentEvent) UniqueConstraints() []*eventstore.UniqueConstraint {
|
|
return nil
|
|
}
|
|
|
|
func (e *PhoneCodeSentEvent) SetBaseEvent(event *eventstore.BaseEvent) {
|
|
e.BaseEvent = event
|
|
}
|
|
|
|
func NewPhoneCodeSentEvent(ctx context.Context, aggregate *eventstore.Aggregate) *PhoneCodeSentEvent {
|
|
return &PhoneCodeSentEvent{
|
|
BaseEvent: eventstore.NewBaseEventForPush(
|
|
ctx,
|
|
aggregate,
|
|
PhoneCodeSentType,
|
|
),
|
|
}
|
|
}
|