π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Avoid charging valid OTT verification attempts
Neeraj Gupta75fbcc19e694
diff --git a/server/pkg/controller/user/userauth.go b/server/pkg/controller/user/userauth.goindex d87f33972b..6de5258454 100644--- a/server/pkg/controller/user/userauth.go+++ b/server/pkg/controller/user/userauth.go@@ -267,7 +267,7 @@ func (c *UserController) verifyEmailOtt(context *gin.Context, email string, ottif err != nil {return stacktrace.Propagate(err, "")}- otts, limited, err := c.UserAuthRepo.ReserveOTTVerificationAttempt(emailHash, app, OTTWrongAttemptLimit)+ otts, limited, err := c.UserAuthRepo.ReserveOTTVerificationAttempt(emailHash, app, ott, OTTWrongAttemptLimit)if err != nil {return stacktrace.Propagate(err, "")}diff --git a/server/pkg/repo/userauth.go b/server/pkg/repo/userauth.goindex 406a574c2f..28eb1859a1 100644--- a/server/pkg/repo/userauth.go+++ b/server/pkg/repo/userauth.go@@ -111,7 +111,7 @@ func (repo *UserAuthRepository) GetValidOTTs(emailHash string, app ente.App) ([]return otts, nil}-func (repo *UserAuthRepository) ReserveOTTVerificationAttempt(emailHash string, app ente.App, limit int) ([]string, bool, error) {+func (repo *UserAuthRepository) ReserveOTTVerificationAttempt(emailHash string, app ente.App, submittedOTT string, limit int) ([]string, bool, error) {tx, err := repo.DB.Begin()if err != nil {return nil, false, stacktrace.Propagate(err, "")@@ -128,6 +128,7 @@ func (repo *UserAuthRepository) ReserveOTTVerificationAttempt(emailHash string,otts := make([]string, 0)limited := false+ matched := falsefor rows.Next() {var ott stringvar wrongAttempt int@@ -136,11 +137,12 @@ func (repo *UserAuthRepository) ReserveOTTVerificationAttempt(emailHash string,}otts = append(otts, ott)limited = limited || wrongAttempt >= limit+ matched = matched || ott == submittedOTT}if err := rows.Err(); err != nil {return nil, false, stacktrace.Propagate(err, "")}- if limited || len(otts) == 0 {+ if limited || len(otts) == 0 || matched {return otts, limited, nil}