Files
zitadel/backend/v3/domain/verification.go
T
5df8a97f9d feat(repository): implement user repository (#10967)
## Summary

This PR introduces the relational user repository for backend v3,
including schema, repository APIs, reducers/projections, and tests for
both human and machine users.

## What changed

* Added user-focused relational migrations (users, verifications,
metadata, PATs, machine keys, passkeys, identity provider links) and
related FK wiring.
* Implemented/expanded repository domain contracts and storage
implementations for human and machine user flows.
* Added support for machine secret handling and aligned access token
type modeling.
* Extended user domain models (verifications, password/email/phone/TOTP
state, passkeys, metadata, invite handling, identity provider links).
* Updated projection/reduction coverage and integration tests for key
user lifecycle events.
* Regenerated and updated mocks/enums plus supporting database
change/column utilities.

## Notes for reviewers

* This PR is large because it establishes the foundational relational
user storage layer and related test scaffolding. Sorry for that.

## Closes

Closes #10218
Closes #10224
Closes #10225
Closes #10209
Closes #10802

---------

Co-authored-by: Iraq Jaber <[email protected]>
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Marco A. <[email protected]>
Co-authored-by: Tim Möhlmann <[email protected]>
2026-02-23 16:03:47 +01:00

99 lines
3.2 KiB
Go

package domain
import (
"time"
"github.com/zitadel/zitadel/internal/crypto"
)
type Verification struct {
ID string `json:"id" db:"id"`
Code *crypto.CryptoValue `json:"code" db:"code"`
CreatedAt time.Time `json:"createdAt" db:"created_at"`
UpdatedAt time.Time `json:"updatedAt" db:"updated_at"`
ExpiresAt *time.Time `json:"expiresAt" db:"expires_at"`
FailedAttempts uint8 `json:"failedAttempts" db:"failed_attempts"`
}
type VerificationType interface {
isVerificationType()
}
// VerificationTypeInit indicates that an object which needs verification is created.
type VerificationTypeInit struct {
// ID is the ID of the verification.
// The id must be set if the the object can have multiple verifications.
ID *string
// CreatedAt is the time when the verification was created.
// If zero, the current time will be used.
CreatedAt time.Time
// Expiry is the duration after which the verification expires.
Expiry *time.Duration
// Code is the code to be used for verification.
Code *crypto.CryptoValue
}
// isVerificationType implements [VerificationType].
func (v *VerificationTypeInit) isVerificationType() {}
var _ VerificationType = (*VerificationTypeInit)(nil)
// VerificationTypeSucceeded indicates that the verification was successful.
// If VerifiedAt is zero, the current time will be used.
type VerificationTypeSucceeded struct {
// ID is the ID of the verification.
// The id must be set if the the object can have multiple verifications.
ID *string
// If zero, the current time will be used.
VerifiedAt time.Time
}
// isVerificationType implements [VerificationType].
func (v *VerificationTypeSucceeded) isVerificationType() {}
var _ VerificationType = (*VerificationTypeSucceeded)(nil)
// VerificationTypeUpdate updates an existing verification.
// Non-nil fields get updated.
type VerificationTypeUpdate struct {
// ID is the ID of the verification.
// The id must be set if the the object can have multiple verifications.
ID *string
Code *crypto.CryptoValue
Expiry *time.Duration
// If zero, the current time will be used.
UpdatedAt time.Time
}
// isVerificationType implements [VerificationType].
func (v *VerificationTypeUpdate) isVerificationType() {}
var _ VerificationType = (*VerificationTypeUpdate)(nil)
// VerificationTypeSkipped indicates that the verification was skipped.
type VerificationTypeSkipped struct {
// ID is the ID of the verification.
// The id must be set if the the object can have multiple verifications.
ID *string
// If zero, the current time will be used.
SkippedAt time.Time
}
// isVerificationType implements [VerificationType].
func (v *VerificationTypeSkipped) isVerificationType() {}
var _ VerificationType = (*VerificationTypeSkipped)(nil)
type VerificationTypeFailed struct {
// ID is the ID of the verification.
// The id must be set if the the object can have multiple verifications.
ID *string
// If zero, the current time will be used.
FailedAt time.Time
}
// isVerificationType implements [VerificationType].
func (v *VerificationTypeFailed) isVerificationType() {}
var _ VerificationType = (*VerificationTypeFailed)(nil)