通过托管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
EXPERTO
preguntada hace 6 meses12 visualizaciones
1 Respuesta
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
EXPERTO
respondido hace 6 meses

No has iniciado sesión. Iniciar sesión para publicar una respuesta.

Una buena respuesta responde claramente a la pregunta, proporciona comentarios constructivos y fomenta el crecimiento profesional en la persona que hace la pregunta.

Pautas para responder preguntas