Skip to main content
import { useState } from 'react';
import { useStytchB2BClient } from '@stytch/react/b2b';

export const ResetBySession = () => {
  const stytch = useStytchB2BClient();
  const [password, setPassword] = useState('');

  const resetPassword = async () => {
    const response = await stytch.passwords.resetBySession({
      password: password,
      organization_id: 'organization-test-07971b06-ac8b-4cdb-9c15-63b17e653931',
    });
    console.log('Password reset:', response);
  };

  return (
    <form>
      <input
        type="password"
        value={password}
        onChange={(e) => setPassword(e.target.value)}
        placeholder="New Password"
      />
      <button onClick={resetPassword} type="submit">Reset Password</button>
    </form>
  );
};

Reset by session

passwords.resetBySession wraps the Reset By Session API endpoint.

Parameters

password
string
required
The password to authenticate, reset, or set for the first time. Any UTF8 character is allowed, e.g. spaces, emojis, non-English characters, etc.

Response

member_id
string
The unique ID of the Member.
member_session
object
The new Stytch Session.
member
object
The Member object of the signed-in Member.
organization
object
The Organization object of the Organization the Member has signed into.
session_jwt
string
The JWT for the new Stytch Session.
If the project is configured to use HttpOnly cookies, this field will always be an empty string.
session_token
string
The secret token for the new Stytch Session.
If the project is configured to use HttpOnly cookies, this field will always be an empty string.
member_device
object
If Protected Auth is enabled and returned fingerprinting results, this field will contain information about the member’s device attributes.
request_id
string
Globally unique UUID that is returned with every API call. This value is important to log for debugging purposes; we may ask for this value to help identify a specific API call when helping you debug an issue.
status_code
number
The HTTP status code of the response. Stytch follows standard HTTP response status code patterns, e.g. 2XX values equate to success, 3XX values are redirects, 4XX are client errors, and 5XX are server errors.