Consumer Authentication

/

Frontend SDKs

/

Headless

/

Passwords

/

Reset by Existing Password

Reset by existing password

The resetByExistingPassword method wraps the reset_by_existing_password Password API endpoint.

If this method succeeds, the user will be logged in, granted an active session, and the session cookies will be minted and stored in the browser.

You can listen for successful login events anywhere in the codebase with the stytch.session.onChange() method or useStytchSession hook if you are using React.


Method parameters


session_duration_minutes*int

email*string

new_password*string

existing_password*string
import React, { useCallback } from 'react';
import { useStytch } from '@stytch/react';

export const Login = () => {
  const stytch = useStytch();

  const resetPassword = useCallback(() => {
    stytch.passwords.resetByExistingPassword({
      existing_password: 'existing_password',
      new_password: '3o#@PcBe)BNj3*jf',
      session_duration_minutes: 60,
      email: 'sandbox@stytch.com',
    });
  }, [stytch]);

  return <button onClick={resetPassword}>Reset Password</button>;
};

RESPONSE

200
{
    "status_code": 200,
    "request_id": "request-id-test-b05c992f-ebdc-489d-a754-c7e70ba13141",
    "user_id": "user-test-16d9ba61-97a1-4ba4-9720-b03761dc50c6"
  }