通过托管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
EXPERTE
gefragt vor 6 Monaten14 Aufrufe
1 Antwort
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
EXPERTE
beantwortet vor 6 Monaten

Du bist nicht angemeldet. Anmelden um eine Antwort zu veröffentlichen.

Eine gute Antwort beantwortet die Frage klar, gibt konstruktives Feedback und fördert die berufliche Weiterentwicklung des Fragenstellers.

Richtlinien für die Beantwortung von Fragen