Allow for timestamps to be saved with accounts (#5049)

* fix_: allow for saving timestamp when saving account

* fix_: associate timestamp to restored account
This commit is contained in:
Sean Hagstrom 2024-04-18 09:34:00 +02:00 committed by GitHub
parent 9e5462eb9e
commit 55e2dc6a90
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 3 additions and 2 deletions

View File

@ -1358,6 +1358,7 @@ func (b *GethStatusBackend) generateOrImportAccount(mnemonic string, customizati
CustomizationColor: multiacccommon.CustomizationColor(request.CustomizationColor),
CustomizationColorClock: customizationColorClock,
KDFIterations: request.KdfIterations,
Timestamp: time.Now().Unix(),
}
if account.KDFIterations == 0 {

View File

@ -323,7 +323,7 @@ func (db *Database) SaveAccount(account Account) error {
account.KDFIterations = dbsetup.ReducedKDFIterationsNumber
}
_, err = db.db.Exec("INSERT OR REPLACE INTO accounts (name, identicon, colorHash, colorId, customizationColor, customizationColorClock, keycardPairing, keyUid, kdfIterations) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)", account.Name, account.Identicon, colorHash, account.ColorID, account.CustomizationColor, account.CustomizationColorClock, account.KeycardPairing, account.KeyUID, account.KDFIterations)
_, err = db.db.Exec("INSERT OR REPLACE INTO accounts (name, identicon, colorHash, colorId, customizationColor, customizationColorClock, keycardPairing, keyUid, kdfIterations, loginTimestamp) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", account.Name, account.Identicon, colorHash, account.ColorID, account.CustomizationColor, account.CustomizationColorClock, account.KeycardPairing, account.KeyUID, account.KDFIterations, account.Timestamp)
if err != nil {
return err
}

View File

@ -28,7 +28,7 @@ func setupTestDB(t *testing.T) (*Database, func()) {
func TestAccounts(t *testing.T) {
db, stop := setupTestDB(t)
defer stop()
expected := Account{Name: "string", KeyUID: "string", CustomizationColor: common.CustomizationColorBlue, ColorHash: ColorHash{{4, 3}, {4, 0}, {4, 3}, {4, 0}}, ColorID: 10, KDFIterations: dbsetup.ReducedKDFIterationsNumber}
expected := Account{Name: "string", KeyUID: "string", CustomizationColor: common.CustomizationColorBlue, ColorHash: ColorHash{{4, 3}, {4, 0}, {4, 3}, {4, 0}}, ColorID: 10, KDFIterations: dbsetup.ReducedKDFIterationsNumber, Timestamp: 1712856359}
require.NoError(t, db.SaveAccount(expected))
accounts, err := db.GetAccounts()
require.NoError(t, err)