Skip to main content

Overview

ForgotPassword component is a user interface element for handling the forgot password process. It includes steps for requesting a code by user e-mail and updating the password. It provides callbacks for handling the completion of the process and navigation to the sign-in page.
You can not customize this component layout structure, design or content.
<ForgotPassword /> component request code step

<ForgotPassword /> component request code step


<ForgotPassword /> component verify and password update step

<ForgotPassword /> component verify and password update step

Props

onComplete
callback
required
A callback function that is called when the forgot password process is successfully completed.
resetPasswordUrl
string
A string representing the URL to reset the password.
onSignUpClick
callback
An optional callback function that is called when the user clicks the sign-in link.

Example Usage

Reference:
forgot-password.tsx
'use client';
import { useCallback } from 'react';
import { useRouter } from 'next/navigation';

import { ForgotPassword } from '@locai1/iam-react';

import { SIGN_IN_PAGE } from '@/const';

export const ForgotPasswordComponent = () => {
  const { push } = useRouter();

  const handleForgotPasswordComplete = useCallback(() => {
    push(SIGN_IN_PAGE);
  }, []);

  const handleSignInClick = useCallback(() => {
    push(SIGN_IN_PAGE);
  }, []);

  const resetPasswordUrl = typeof window !== 'undefined' ?
    `${window.location.origin}/forgot-password?code={{code}}` :
    `/forgot-password?code={{code}}`;

  return (
    <div className="flex items-center justify-center min-h-screen bg-gray-100">
      <ForgotPassword
        onComplete={handleForgotPasswordComplete}
        onSignInClick={handleSignInClick}
        resetPasswordUrl={resetPasswordUrl}
      />
    </div>
  );
};