Recover Password

To start the password recovery process for an existing user account, the accounts.recover_password() method can be called from your component:

/ui/pages/recover_password/index.js

import joystick, { accounts } from '@joystick.js/ui';

const RecoverPassword = joystick.component({
  events: {
    'submit form': (event = {}) => {
      accounts.recover_password({
        email_address: event.target.email_address.value,
      }).then(() => {
        window.alert(`Check your email address at ${event.target.email_address.value} for a reset link!`);
      });
    },
  },
  render: () => {
    return `
      <div class="recover-password">
        <form>
          <label>Email Address</label>
          <input type="email" name="email_address" placeholder="Email Address" />
          <button type="submit">Recover Password</button>
        </form>
      </div>
    `;
  },
});

export default RecoverPassword;

Above, we listen for a submit event on our <form></form> element, calling to accounts.recover_password() to start the password recovery process for an existing user. Because we expect accounts.recover_password() to return a Promise, we use a .then() callback if the request is successful, alerting the user to check their email for a reset link.

API Reference

accounts.recover_password()

Function API

Function API

accounts.recover_password(options: object) => Promise;

Arguments

  • options object

    An object defining the parameters for the existing user account.

    • email_address string Required

      A string defining the email address for the existing user account.

On This Page