create
Creates an account. The account is given a public key, which is what Holster uses to identify it and where its data is stored.
Parameter | Description |
|---|---|
| The username to log in with. |
| The password to log in with. |
| Optional function that receives |
A username that's already taken returns "Username already exists". That check can't stop two accounts being created with the same username at the same time though, so usernames aren't guaranteed to be unique. Use the account's public key, user.is.pub, to identify it. Without a callback, errors are logged to the console.
Creating an account doesn't log in to it. Call auth() afterwards.
Examples
// Create an account, then log in to it.
user.create("alice", "a strong password", err => {
if (err) return console.error(err)
user.auth("alice", "a strong password", err => {
if (err) return console.error(err)
console.log("logged in as", user.is.username)
})
})
// Without a callback, errors are logged to the console.
user.create("bob", "another strong password")