通过托管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ヶ月前

ログインしていません。 ログイン 回答を投稿する。

優れた回答とは、質問に明確に答え、建設的なフィードバックを提供し、質問者の専門分野におけるスキルの向上を促すものです。

質問に答えるためのガイドライン