mirror of
https://github.com/zitadel/zitadel.git
synced 2025-08-12 13:07:31 +00:00
chore: move the go code into a subfolder
This commit is contained in:
57
apps/api/internal/v2/user/human_added.go
Normal file
57
apps/api/internal/v2/user/human_added.go
Normal file
@@ -0,0 +1,57 @@
|
||||
package user
|
||||
|
||||
import (
|
||||
"golang.org/x/text/language"
|
||||
|
||||
"github.com/zitadel/zitadel/internal/crypto"
|
||||
"github.com/zitadel/zitadel/internal/domain"
|
||||
"github.com/zitadel/zitadel/internal/v2/eventstore"
|
||||
"github.com/zitadel/zitadel/internal/zerrors"
|
||||
)
|
||||
|
||||
const HumanAddedType = AggregateType + ".human.added"
|
||||
|
||||
type humanAddedPayload struct {
|
||||
Username string `json:"userName"`
|
||||
|
||||
FirstName string `json:"firstName,omitempty"`
|
||||
LastName string `json:"lastName,omitempty"`
|
||||
NickName string `json:"nickName,omitempty"`
|
||||
DisplayName string `json:"displayName,omitempty"`
|
||||
PreferredLanguage language.Tag `json:"preferredLanguage,omitempty"`
|
||||
Gender domain.Gender `json:"gender,omitempty"`
|
||||
|
||||
EmailAddress domain.EmailAddress `json:"email,omitempty"`
|
||||
PhoneNumber domain.PhoneNumber `json:"phone,omitempty"`
|
||||
|
||||
// New events only use EncodedHash. However, the secret field
|
||||
// is preserved to handle events older than the switch to Passwap.
|
||||
Secret *crypto.CryptoValue `json:"secret,omitempty"`
|
||||
EncodedHash string `json:"encodedHash,omitempty"`
|
||||
PasswordChangeRequired bool `json:"changeRequired,omitempty"`
|
||||
}
|
||||
|
||||
type HumanAddedEvent eventstore.Event[humanAddedPayload]
|
||||
|
||||
var _ eventstore.TypeChecker = (*HumanAddedEvent)(nil)
|
||||
|
||||
// ActionType implements eventstore.Typer.
|
||||
func (c *HumanAddedEvent) ActionType() string {
|
||||
return HumanAddedType
|
||||
}
|
||||
|
||||
func HumanAddedEventFromStorage(event *eventstore.StorageEvent) (e *HumanAddedEvent, _ error) {
|
||||
if event.Type != e.ActionType() {
|
||||
return nil, zerrors.ThrowInvalidArgument(nil, "USER-MRZ3p", "Errors.Invalid.Event.Type")
|
||||
}
|
||||
|
||||
payload, err := eventstore.UnmarshalPayload[humanAddedPayload](event.Payload)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &HumanAddedEvent{
|
||||
StorageEvent: event,
|
||||
Payload: payload,
|
||||
}, nil
|
||||
}
|
Reference in New Issue
Block a user