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

[FR] Authenticator - How to initiate confirm sign-in with new password? #4996

Open
4 tasks done
ssljivic opened this issue Feb 9, 2024 · 3 comments
Open
4 tasks done
Labels
Authenticator An issue or a feature-request for an Authenticator UI Component feature-request Request a new feature

Comments

@ssljivic
Copy link

ssljivic commented Feb 9, 2024

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?

Vite

What browsers are you seeing the problem on?

Chrome

Which region are you seeing the problem in?

No response

Please describe your bug.

When a new user is created in Cognito, an email with a link that has the initial password and the user's email is sent.
An example of the link would be https://my.webapp/[email protected]&password=12345678

I could not find any documentation or sample that shows how to show the amplify UI for confirm sing-in with new password.

What's the expected behaviour?

I would like to directly show the user the change password interface and somehow pass the username and password that came from the URL query,m so that the user does not have to enter them manually.

Help us reproduce the bug!

N/A

Code Snippet

No response

Console log output

No response

Additional information and screenshots

No response

@github-actions github-actions bot added the pending-triage Issue is pending triage label Feb 9, 2024
@ssljivic
Copy link
Author

ssljivic commented Feb 9, 2024

I could create my own UI to collect new user password, but I would like to reuse the existing amplify-ui for that.

@ssljivic
Copy link
Author

ssljivic commented Feb 9, 2024

The best I could do for now is to pre-fill username and password:

formFields={{
      signIn: {
        username: {
          defaultValue: username,
          isReadOnly: true,
        },
        password: {
          defaultValue: password,
          isReadOnly: true,
        },
      },
    }}

However, the user still needs to submit the form, which is not ideal.
After the sign-in form is submitted amiplify-ui correctly shows the change-password form.

@hbuchel hbuchel added question General question Authenticator An issue or a feature-request for an Authenticator UI Component labels Feb 9, 2024
@ssljivic
Copy link
Author

In the end, I ended up using useAuthenticator and its' submitForm function:

const auth = useAuthenticator((ctx) => [ctx.authStatus])
...
auth.submitForm({
        type: 'SIGN_IN',
        username: searchParams.get('email'),
        password: searchParams.get('code'),
      })

However, I saw a comment that submitForm is intended for internal use and that it is not mentioned in the documentation for that reason. It would be nice to have an "official" way to achieve this, but for now, this will do the trick.

@reesscot reesscot added being-investigated An issue or a feature-request is being investigated and removed pending-triage Issue is pending triage labels Feb 19, 2024
@reesscot reesscot added feature-request Request a new feature and removed question General question labels Apr 16, 2024
@reesscot reesscot changed the title QUESTION: How to initiate confirm sign-in with new password? [FR] Authenticator - How to initiate confirm sign-in with new password? Apr 16, 2024
@reesscot reesscot removed the being-investigated An issue or a feature-request is being investigated label Apr 16, 2024
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