mirror of
https://github.com/andwati/zitadel.git
synced 2026-11-26 06:18:46 +00:00
feat: implement otp sms session challenge (#11919)
# Which Problems Are Solved This PR adds the OTP SMS Challenge needed for CreateSession API https://github.com/zitadel/zitadel/issues/11035 # How the Problems Are Solved - Introduce `OTPSMSChallengeCommand` (validate/execute/events) for session creation checks - Introduce `GetOTPCryptoGeneratorConfigWithDefault` to fetch per-instance secret generator settings - Add unit tests # Additional Changes Refactor tests in `session_check_recovery_code_test.go` to make the helper functions reusable in `session_challenge_otp_sms_test.go` # Additional Context Related to https://github.com/zitadel/zitadel/issues/11035
This commit is contained in:
@@ -2,7 +2,6 @@ package domain
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"time"
|
||||
|
||||
"github.com/zitadel/zitadel/backend/v3/instrumentation/logging"
|
||||
@@ -88,11 +87,8 @@ func (rc *RecoveryCodeCheckCommand) Validate(ctx context.Context, opts *InvokeOp
|
||||
opts.DB(),
|
||||
database.WithCondition(sessionRepo.PrimaryKeyCondition(rc.InstanceID, rc.SessionID)),
|
||||
)
|
||||
if err != nil {
|
||||
if errors.Is(err, &database.NoRowFoundError{}) {
|
||||
return zerrors.ThrowNotFound(err, "DOM-Ot3qO6", "Errors.Session.NotFound")
|
||||
}
|
||||
return zerrors.ThrowInternal(err, "DOM-2sF2kF", "Errors.Internal")
|
||||
if err := handleGetError(err, "DOM-2sF2kF", objectTypeSession); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if retrievedSession.UserID == "" {
|
||||
@@ -107,11 +103,8 @@ func (rc *RecoveryCodeCheckCommand) Validate(ctx context.Context, opts *InvokeOp
|
||||
database.WithCondition(userRepo.IDCondition(retrievedSession.UserID)),
|
||||
database.WithResultLock(),
|
||||
)
|
||||
if err != nil {
|
||||
if errors.Is(err, &database.NoRowFoundError{}) {
|
||||
return zerrors.ThrowNotFound(err, "DOM-Ot3qO6", "Errors.User.NotFound")
|
||||
}
|
||||
return zerrors.ThrowInternal(err, "DOM-7sWTNf", "Errors.Internal")
|
||||
if err := handleGetError(err, "DOM-Ot3qO6", objectTypeUser); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// check user state
|
||||
|
||||
Reference in New Issue
Block a user