diff --git a/internal/api/verify.go b/internal/api/verify.go index 1040ce7c6..c0b78d680 100644 --- a/internal/api/verify.go +++ b/internal/api/verify.go @@ -306,6 +306,7 @@ func (a *API) verifyPost(w http.ResponseWriter, r *http.Request, params *VerifyP func (a *API) signupVerify(r *http.Request, ctx context.Context, conn *storage.Connection, user *models.User) (*models.User, error) { config := a.config + shouldUpdatePassword := false if !user.HasPassword() && user.InvitedAt != nil { // sign them up with temporary password, and require application // to present the user with a password set form @@ -318,11 +319,12 @@ func (a *API) signupVerify(r *http.Request, ctx context.Context, conn *storage.C if err := user.SetPassword(ctx, password, config.Security.DBEncryption.Encrypt, config.Security.DBEncryption.EncryptionKeyID, config.Security.DBEncryption.EncryptionKey); err != nil { return nil, err } + shouldUpdatePassword = true } err := conn.Transaction(func(tx *storage.Connection) error { var terr error - if !user.HasPassword() && user.InvitedAt != nil { + if shouldUpdatePassword { if terr = user.UpdatePassword(tx, nil); terr != nil { return internalServerError("Error storing password").WithInternalError(terr) }