Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

forceNewpassword authState never set in useAuthenticator context #4774

Closed
4 tasks done
bardiakhosravi opened this issue Nov 20, 2023 · 3 comments
Closed
4 tasks done
Labels
Authenticator An issue or a feature-request for an Authenticator UI Component feature-request Request a new feature

Comments

@bardiakhosravi
Copy link

Before creating a new issue, please confirm:

On which framework/platform are you having an issue?

React

Which UI component?

Authenticator

How is your app built?

Create React App

What browsers are you seeing the problem on?

Chrome

Which region are you seeing the problem in?

No response

Please describe your bug.

  • I am using the Authenticator component.
  • Also using the useAuthenticator hook

I have a user in a user pool whose temporary password has expired and the user confirmation status is set to Force change password.

When I use the Authenticator component to sign in with the user email I see an error in the Authenticator component stating Temporary password has expired and must be reset by an administrator.

However, the context object passed to the useAuthenticator hook never gets an authState that is equal to forceNewPassword or any other state that I can use to handle the situation. It remains unauthenticated.

What's the expected behaviour?

The context object should have a state that represents the user state in cognito, specifically in this case that forceNewPassword.

Help us reproduce the bug!

  • have a user in a cognito user pool with a force change password state.
  • use Authenticator component to sign in using this user's email address
  • look at useAuthenticator context object and the authState value does not reflect this user state.

Code Snippet

export default function AmplifyAuthenticator() {
  let location = useLocation();
  const navigate = useNavigate();
  const { authStatus, route } = useAuthenticator((context) => {
    return [context.authStatus, context.route];
  });

  console.log("authState", authStatus, route);

  let from = location.state?.from?.pathname || "/";

  const handleClose = () => {
    navigate(-1);
  };

  return (
    <Dialog open={true} onClose={handleClose}>
      <Authenticator loginMechanisms={["email"]}>
        {({ signOut, user }) => {
          return <Navigate to={from} />;
        }}
      </Authenticator>
    </Dialog>
  );
}

Console log output

No response

Additional information and screenshots

Screenshot 2023-11-20 at 5 24 54 PM

package.json

@github-actions github-actions bot added the pending-triage Issue is pending triage label Nov 20, 2023
@esauerbo esauerbo added Authenticator An issue or a feature-request for an Authenticator UI Component being-investigated and removed pending-triage Issue is pending triage labels Nov 21, 2023
@esauerbo
Copy link
Contributor

esauerbo commented Nov 21, 2023

Hi @bardiakhosravi, thanks for raising this.

authStatus intentionally reflects only whether the user is authenticated or unauthenticated (or configuring, if the Authenticator is loading). Documentation for that.

If you want to add event handling in the case of forceNewPassword you would want to use the route variable. And here's the documentation.

Hopefully this helps and please let us know if this adequately addresses your use-case.

@esauerbo
Copy link
Contributor

@bardiakhosravi following up, in the specific case where the temporary password is expired, the route will not show that state. At this time, there is no way to reflect that the temporary password is expired from the UI side. The admin user must resend a temporary password.

Here are the cognito docs about this (Temporary Password section) https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_AdminCreateUser.html

@esauerbo esauerbo added the feature-request Request a new feature label Nov 21, 2023
@reesscot
Copy link
Contributor

This state is not exposed because there is nothing that can be done about it from the UI layer other than displaying the message. When a user is in this state an administrator will need to setup a new password from Cognito, which cannot be done from the UI. Closing this out, since we don't plan on supporting this feature.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Authenticator An issue or a feature-request for an Authenticator UI Component feature-request Request a new feature
Projects
None yet
Development

No branches or pull requests

3 participants