basic Login component

Hello, everyone, how are the events of the Login component defined.e.g handle submit, its not indicated in the documentation

Hey Mothusi,

Welcome here! (as I see this is your first post).

This documentation states you can add event listeners to your LoginOverlay component:

Here is some example code of how you can achieve this:

export default function LoginView() {

  const navigate = useNavigate();

  return (
    <LoginOverlay
      opened
      onLogin={async ({ detail: { username, password } }) => {
        const { defaultUrl, error, redirectUrl } = await login(username, password);

        if (error) {
          // log it or flag the error
        } else {
             // handle the login somehow if there was no error.
          const url = redirectUrl ?? defaultUrl ?? '/';
          const path = new URL(url, document.baseURI).pathname;
          navigate(path);
        }
      }}
    />
  );
}
1 Like

Here is the same as in the previous post applied in fully functional demo app

2 Likes