Registers a new user by creating an account with the provided credentials. Required fields should be configured in config.json.
await client.auth().register({ username: "mike", password: "mikes-wife-birthday", email: "mike@example.com" })The password will be hashed if you configure it as described in the REST documentation.
The register() method returns a token object containing both an access token and a refresh token. If the request is made from a browser environment, only the access token is included in the response, while the refresh token is stored in an HTTP-only cookie.
const token = await client.auth().register({ username: "mike", password: "mikes-wife-birthday", email: "mike@example.com" })
//console.log(token)
// result:
// {
// access: "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."
// }
If you need to save the token for future use, retrieve it from the client.auth().on("register", token => { /* save token */ }) event instead of this result.