Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update account timestamp when login with keycard (#1613) #1614

Merged
merged 1 commit into from
Sep 24, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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