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:
parent
9e5462eb9e
commit
55e2dc6a90
|
@ -1358,6 +1358,7 @@ func (b *GethStatusBackend) generateOrImportAccount(mnemonic string, customizati
|
||||||
CustomizationColor: multiacccommon.CustomizationColor(request.CustomizationColor),
|
CustomizationColor: multiacccommon.CustomizationColor(request.CustomizationColor),
|
||||||
CustomizationColorClock: customizationColorClock,
|
CustomizationColorClock: customizationColorClock,
|
||||||
KDFIterations: request.KdfIterations,
|
KDFIterations: request.KdfIterations,
|
||||||
|
Timestamp: time.Now().Unix(),
|
||||||
}
|
}
|
||||||
|
|
||||||
if account.KDFIterations == 0 {
|
if account.KDFIterations == 0 {
|
||||||
|
|
|
@ -323,7 +323,7 @@ func (db *Database) SaveAccount(account Account) error {
|
||||||
account.KDFIterations = dbsetup.ReducedKDFIterationsNumber
|
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 {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,7 +28,7 @@ func setupTestDB(t *testing.T) (*Database, func()) {
|
||||||
func TestAccounts(t *testing.T) {
|
func TestAccounts(t *testing.T) {
|
||||||
db, stop := setupTestDB(t)
|
db, stop := setupTestDB(t)
|
||||||
defer stop()
|
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))
|
require.NoError(t, db.SaveAccount(expected))
|
||||||
accounts, err := db.GetAccounts()
|
accounts, err := db.GetAccounts()
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
Loading…
Reference in New Issue