store

Remembers the logged in user in the browser, so they can be logged in again with recall() without entering their password.

Parameter

Description

local

Optional. When true, uses local storage. Otherwise uses session storage.

Session storage is cleared when the browser is closed, while local storage keeps the credentials until the user logs out with leave(). They're stored under the name user.is, and storing in one removes any copy from the other.

store() must be called after a successful auth(), otherwise it logs an error and stores nothing.

Examples

user.auth("alice", "a strong password", err => {
  if (err) return console.error(err)

  // Stay logged in until the browser is closed.
  user.store()
})

user.auth("alice", "a strong password", err => {
  if (err) return console.error(err)

  // Stay logged in until the user logs out.
  user.store(true)
})

The stored credentials include the account's private keys, so only use local storage on a device the user trusts.