通过托管UI使用Cognito otpauth名称

0

【以下的问题经过翻译处理】 您好,

我正在使用托管的Cognito UI进行登录或者重置TOTP,并且希望谷歌验证码显示我的自定义应用程序名称,但它显示为“AWSCognito”。

我了解只有使用API才可以修改AWSCognito,如此处所示otpauth://totp / AWSCognito:$ {email}?secret = $ {code}&issuer = https://cognito-idp.ap-southeast-2.amazonaws.com/

有没有使用托管UI的方法?

profile picture
전문가
질문됨 6달 전12회 조회
1개 답변
0

【以下的回答经过翻译处理】 这个问题已经解决了。需要的人可以按照以下步骤操作:

首先将下面的代码引入你的项目中:

import {
  Authenticator,
  Heading,
  Text,
  ThemeProvider,
  Theme,
  useTheme,
  View,
  useAuthenticator,
  Button,
} from '@aws-amplify/ui-react'

然后在你的应用程序中添加授权提供者:

 <Authenticator
          hideSignUp={true}
          formFields={formFields}
          components={components}
        >
          <Layout>
            <main>
              <Component previousPathname={previousPathname} {...pageProps} />
            </main>
          </Layout>
        </Authenticator>

最后配置表单字段即可:

const formFields = {
  setupTOTP: {
    QR: {
      totpIssuer: `CompanyName - ${process.env.NEXT_PUBLIC_ENV}`,
      totpUsername: email,
    },
...
  },
}

profile picture
전문가
답변함 6달 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인