Skip to content

Commit

Permalink
update account timestamp when login with keycard (#1613)
Browse files Browse the repository at this point in the history
  • Loading branch information
yenda committed Sep 23, 2019
1 parent d263be1 commit 84f5b10
Showing 1 changed file with 21 additions and 4 deletions.
25 changes: 21 additions & 4 deletions api/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ func (b *StatusBackend) SaveAccountAndStartNodeWithKey(acc multiaccounts.Account

// StartNodeWithKey instead of loading addresses from database this method derives address from key
// and uses it in application.
func (b *StatusBackend) StartNodeWithKey(acc multiaccounts.Account, password string, keyHex string) error {
func (b *StatusBackend) startNodeWithKey(acc multiaccounts.Account, password string, keyHex string) error {
err := b.ensureAppDBOpened(acc, password)
if err != nil {
return err
Expand All @@ -226,7 +226,6 @@ func (b *StatusBackend) StartNodeWithKey(acc multiaccounts.Account, password str
return err
}
err = b.StartNode(conf)
signal.SendLoggedIn(err)
if err != nil {
return err
}
Expand All @@ -236,7 +235,25 @@ func (b *StatusBackend) StartNodeWithKey(acc multiaccounts.Account, password str
return err
}
b.accountManager.SetAccountAddresses(chatAcc.Address)
return b.injectAccountIntoServices()
err = b.injectAccountIntoServices()
if err != nil {
return err
}
err = b.multiaccountsDB.UpdateAccountTimestamp(acc.Address, time.Now().Unix())
if err != nil {
return err
}
return nil
}

func (b *StatusBackend) StartNodeWithKey(acc multiaccounts.Account, password string, keyHex string) error {
err := b.startNodeWithKey(acc, password, keyHex)
if err != nil {
// Stop node for clean up
_ = b.StopNode()
}
signal.SendLoggedIn(err)
return err
}

func (b *StatusBackend) startNodeWithAccount(acc multiaccounts.Account, password string) error {
Expand Down Expand Up @@ -287,11 +304,11 @@ func (b *StatusBackend) startNodeWithAccount(acc multiaccounts.Account, password

func (b *StatusBackend) StartNodeWithAccount(acc multiaccounts.Account, password string) error {
err := b.startNodeWithAccount(acc, password)
signal.SendLoggedIn(err)
if err != nil {
// Stop node for clean up
_ = b.StopNode()
}
signal.SendLoggedIn(err)
return err
}

Expand Down

0 comments on commit 84f5b10

Please sign in to comment.