AmplifyTotpSetup component renders broken image for QR code
See original GitHub issueDescribe the bug
The QR Code image for TOTP Setup fails to render if AmplifyTotpSetup
is used in AmplifyAuthenticator
To Reproduce Steps to reproduce the behavior:
- Create auth flow with
<AmplifyAuthenticator >...</AmplifyAuthenticator>
- Add
<AmplifyTotpSetup slot="totp-setup" />
child - Register a new user or sign in with one that still needs TOTP Setup
- View broken qr code…
Expected behavior QR Code renders correctly with no overrides, with issuer override, with header text override, etc
Code Snippet
import React from "react";
import "./App.css";
import Amplify from "aws-amplify";
import {
AmplifyAuthenticator,
AmplifySignOut,
AmplifyTotpSetup,
} from "@aws-amplify/ui-react";
import { AuthState, onAuthUIStateChange } from "@aws-amplify/ui-components";
import awsconfig from "./aws-exports";
Amplify.configure(awsconfig);
const AuthStateApp: React.FunctionComponent = () => {
const [authState, setAuthState] = React.useState<AuthState>();
const [user, setUser] = React.useState<object | undefined>();
React.useEffect(() => {
return onAuthUIStateChange((nextAuthState, authData) => {
setAuthState(nextAuthState);
setUser(authData);
});
}, []);
return authState === AuthState.SignedIn && user ? (
<div className="App">
<div>Hello, {(user as any).username}</div>
<AmplifySignOut />
</div>
) : (
<AmplifyAuthenticator >
<AmplifyTotpSetup headerText="My Custom TOTP Setup Text" slot="totp-setup" />
</AmplifyAuthenticator>
);
};
export default AuthStateApp;
Screenshots
Working if you don’t use the AmplifyTotpSetup
component:
Broken with no overrides <AmplifyTotpSetup slot="totp-setup" />
Broken with overrides <AmplifyTotpSetup headerText="My Custom TOTP Setup Text" slot="totp-setup" />
Issue Analytics
- State:
- Created 3 years ago
- Reactions:4
- Comments:14 (5 by maintainers)
Top Results From Across the Web
React app loads images locally, but AWS Amplify does not ...
In my case, AWS Amplify was not playing nice with SVG images. Changed them to PNG and the issue was resolved.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
That being said, I see that having to pass
user
manually is cumbersome. I’ll bring this up to the team and discuss if we can reduce this complexity.In case it is useful to anybody, here is what I did as a temporary workaround for a custom issuer in TOTP setup until #7522 is merged: