Skip to content

Commit

Permalink
fix: allow updating just the verified_at timestamp of addresses
Browse files Browse the repository at this point in the history
  • Loading branch information
alnr committed Apr 17, 2024
1 parent e942507 commit 0d57de9
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion identity/identity_verification.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,5 +118,5 @@ func (a VerifiableAddress) ValidateNID() error {

// Hash returns a unique string representation for the recovery address.
func (a VerifiableAddress) Hash() string {
return fmt.Sprintf("%v|%v|%v|%v|%v|%v", a.Value, a.Verified, a.Via, a.Status, a.IdentityID, a.NID)
return fmt.Sprintf("%v|%v|%v|%v|%v|%v|%v", a.Value, a.Verified, a.Via, a.Status, a.VerifiedAt, a.IdentityID, a.NID)
}
9 changes: 4 additions & 5 deletions identity/identity_verification_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ func TestNewVerifiableEmailAddress(t *testing.T) {
}

var tagsIgnoredForHashing = map[string]struct{}{
"id": {},
"created_at": {},
"updated_at": {},
"verified_at": {},
"id": {},
"created_at": {},
"updated_at": {},
// "verified_at": {}, // we explicitly want to be able to update just this field and nothing else
}

func reflectiveHash(record any) string {
Expand Down Expand Up @@ -102,5 +102,4 @@ func TestVerifiableAddress_Hash(t *testing.T) {
)
})
}

}
3 changes: 3 additions & 0 deletions persistence/sql/identity/persister_identity.go
Original file line number Diff line number Diff line change
Expand Up @@ -477,6 +477,9 @@ func (p *IdentityPersister) normalizeVerifiableAddresses(ctx context.Context, id
if v.Verified && (v.VerifiedAt == nil || time.Time(*v.VerifiedAt).IsZero()) {
v.VerifiedAt = pointerx.Ptr(sqlxx.NullTime(time.Now()))
}
if !v.Verified {
v.VerifiedAt = pointerx.Ptr(sqlxx.NullTime{})
}

id.VerifiableAddresses[k] = v
}
Expand Down

0 comments on commit 0d57de9

Please sign in to comment.