Files
zitadel/backend/v3/domain/humangender_enumer.go
T
f5ce288ea5 feat(domain): define user repositories (#11059)
This pull request introduces a new set of domain models and repositories
for managing users within the new v3 structure. The goal is to establish
a clean, robust, and extensible foundation for user management.

### Summary

This PR accomplishes the following:

- **Polymorphic User Model**: Introduces a `User` model in user.go that
can represent either a `Human` or a `Machine` user. This provides a
unified way to handle different user types while allowing for specific
attributes and logic for each.
- **Repository Pattern**: Implements the repository pattern for
accessing and manipulating user data. This decouples the business logic
from the data storage implementation. The main repository interfaces
(`UserRepository`, `HumanUserRepository`, `MachineUserRepository`) are
now defined in `backend/v3/domain/user_repository.go`.
- **Comprehensive User Models**: The user.go file now also defines the
domain models for associated user data, including `UserMetadata`,
`IdentityProviderLink`, `Passkey`, `PersonalAccessToken`, and
`MachineKey`.
- **Generic Verification and Check System**: Introduces verification.go
and check.go to provide a standardized way of handling various
verification flows (e.g., email verification, OTP checks).
- **Generated Code**: Adds new generated files for enums
(`humangender_enumer.go`, `machinekeytype_enumer.go`,
`passkeytype_enumer.go`, `personalaccesstokentype_enumer.go`,
`userstate_enumer.go`, `usertype_enumer.go`) and mocks for the new
repositories.
- **Session Domain Refactoring**: Updates the session domain
(`backend/v3/domain/session*.go`) to align with the new user model
structure.

This foundational work paves the way for migrating user management logic
to the new `v3` backend, with a more maintainable and testable
architecture.

part of #10224

---------

Co-authored-by: Copilot <[email protected]>
Co-authored-by: Marco A. <[email protected]>
2025-11-25 11:54:32 +01:00

87 lines
2.5 KiB
Go

// Code generated by "enumer -type HumanGender -transform lower -trimprefix HumanGender"; DO NOT EDIT.
package domain
import (
"fmt"
"strings"
)
const _HumanGenderName = "unspecifiedfemalemalediverse"
var _HumanGenderIndex = [...]uint8{0, 11, 17, 21, 28}
const _HumanGenderLowerName = "unspecifiedfemalemalediverse"
func (i HumanGender) String() string {
if i >= HumanGender(len(_HumanGenderIndex)-1) {
return fmt.Sprintf("HumanGender(%d)", i)
}
return _HumanGenderName[_HumanGenderIndex[i]:_HumanGenderIndex[i+1]]
}
// An "invalid array index" compiler error signifies that the constant values have changed.
// Re-run the stringer command to generate them again.
func _HumanGenderNoOp() {
var x [1]struct{}
_ = x[HumanGenderUnspecified-(0)]
_ = x[HumanGenderFemale-(1)]
_ = x[HumanGenderMale-(2)]
_ = x[HumanGenderDiverse-(3)]
}
var _HumanGenderValues = []HumanGender{HumanGenderUnspecified, HumanGenderFemale, HumanGenderMale, HumanGenderDiverse}
var _HumanGenderNameToValueMap = map[string]HumanGender{
_HumanGenderName[0:11]: HumanGenderUnspecified,
_HumanGenderLowerName[0:11]: HumanGenderUnspecified,
_HumanGenderName[11:17]: HumanGenderFemale,
_HumanGenderLowerName[11:17]: HumanGenderFemale,
_HumanGenderName[17:21]: HumanGenderMale,
_HumanGenderLowerName[17:21]: HumanGenderMale,
_HumanGenderName[21:28]: HumanGenderDiverse,
_HumanGenderLowerName[21:28]: HumanGenderDiverse,
}
var _HumanGenderNames = []string{
_HumanGenderName[0:11],
_HumanGenderName[11:17],
_HumanGenderName[17:21],
_HumanGenderName[21:28],
}
// HumanGenderString retrieves an enum value from the enum constants string name.
// Throws an error if the param is not part of the enum.
func HumanGenderString(s string) (HumanGender, error) {
if val, ok := _HumanGenderNameToValueMap[s]; ok {
return val, nil
}
if val, ok := _HumanGenderNameToValueMap[strings.ToLower(s)]; ok {
return val, nil
}
return 0, fmt.Errorf("%s does not belong to HumanGender values", s)
}
// HumanGenderValues returns all values of the enum
func HumanGenderValues() []HumanGender {
return _HumanGenderValues
}
// HumanGenderStrings returns a slice of all String values of the enum
func HumanGenderStrings() []string {
strs := make([]string, len(_HumanGenderNames))
copy(strs, _HumanGenderNames)
return strs
}
// IsAHumanGender returns "true" if the value is listed in the enum definition. "false" otherwise
func (i HumanGender) IsAHumanGender() bool {
for _, v := range _HumanGenderValues {
if i == v {
return true
}
}
return false
}