通过托管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
专家
已提问 5 个月前8 查看次数
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
专家
已回答 5 个月前

您未登录。 登录 发布回答。

一个好的回答可以清楚地解答问题和提供建设性反馈,并能促进提问者的职业发展。

回答问题的准则