Skip to content
Snippets Groups Projects
Commit d030d23f authored by Josh Brooks's avatar Josh Brooks
Browse files

Merge branch 'hotfix/verify-not-found' into 'hotfix/flattend-username'

InsertFactTwilio should update columns on conflict

See merge request elixxir/user-discovery-bot!43
parents 0ae09cea 723666a5
No related branches found
No related tags found
4 merge requests!50Revert "update deps",!48Release,!43InsertFactTwilio should update columns on conflict,!42Add username field to users table for raw username
...@@ -92,9 +92,12 @@ func (db *DatabaseImpl) InsertFactTwilio(userID, factHash, signature []byte, fac ...@@ -92,9 +92,12 @@ func (db *DatabaseImpl) InsertFactTwilio(userID, factHash, signature []byte, fac
} }
tf := func(tx *gorm.DB) error { tf := func(tx *gorm.DB) error {
// TODO: THIS IS A RACE CONDITION
// currently, unverified facts can be overwritten. When registerFact (io/factRegistration.go) is called,
// it searches for VERIFIED facts with the hash on line 53. This means that unverified facts can compete with each other
return tx.Clauses(clause.OnConflict{ return tx.Clauses(clause.OnConflict{
Columns: []clause.Column{{Name: "hash"}}, Columns: []clause.Column{{Name: "hash"}},
DoUpdates: clause.AssignmentColumns([]string{"timestamp"}), UpdateAll: true,
}).Create(f).Error }).Create(f).Error
} }
......
...@@ -35,8 +35,8 @@ func (m *Manager) RegisterFact(uid *id.ID, fact string, factType uint8, signatur ...@@ -35,8 +35,8 @@ func (m *Manager) RegisterFact(uid *id.ID, fact string, factType uint8, signatur
} else { } else {
to = fact to = fact
channel = Email.String() channel = Email.String()
} }
verifyId, err := m.verifier.Verification(to, channel) verifyId, err := m.verifier.Verification(to, channel)
jww.INFO.Printf("Sent verification & received %s", verifyId) jww.INFO.Printf("Sent verification & received %s", verifyId)
if err != nil { if err != nil {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment