aws-amplify / amplify-ui

Amplify UI is a collection of accessible, themeable, performant React (and more!) components that can connect directly to the cloud.
https://ui.docs.amplify.aws
Apache License 2.0
882 stars 279 forks source link

Resetting the password causes the user to get stuck #278

Closed jssuttles closed 2 years ago

jssuttles commented 3 years ago

Before opening, please confirm:

Is this a production issue?

JavaScript Framework

Vue

Amplify APIs

Authentication

Amplify Categories

storage

Environment information

``` System: OS: macOS 11.2.1 CPU: (12) x64 Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz Memory: 217.58 MB / 16.00 GB Shell: 5.8 - /bin/zsh Binaries: Node: 14.16.0 - ~/.nvm/versions/node/v14.16.0/bin/node Yarn: 1.22.10 - ~/Documents/medicom/server/node_modules/.bin/yarn npm: 6.14.11 - ~/.nvm/versions/node/v14.16.0/bin/npm Browsers: Chrome: 89.0.4389.82 Edge: 89.0.774.48 Firefox: 77.0.1 Safari: 14.0.3 npmPackages: @aws-amplify/ui-components: ^1.0.3 => 1.0.3 @aws-amplify/ui-vue: ^1.0.3 => 1.0.3 @babel/core: ^7.7.4 => 7.7.4 @babel/preset-env: ^7.7.4 => 7.7.4 @babel/preset-react: ^7.7.4 => 7.7.4 @google/maps: ^1.1.3 => 1.1.3 @ibm/plex: ^3.0.0 => 3.0.0 @mdi/font: ^5.8.55 => 5.8.55 @medicomtechnologies/pl-api-status-check: ^1.3.0 => 1.3.0 @medicomtechnologies/routingruleengine: 1.0.25 => 1.0.25 @tsconfig/node12: ^1.0.7 => 1.0.7 @types/bluebird: ^3.5.33 => 3.5.33 @types/clone: ^2.1.0 => 2.1.0 @types/express: ^4.17.11 => 4.17.11 @types/express-session: ^1.17.3 => 1.17.3 @types/http-status-codes: ^1.2.0 => 1.2.0 @types/jest: ^26.0.20 => 26.0.20 @types/jsonwebtoken: ^8.5.0 => 8.5.0 @types/jwk-to-pem: ^2.0.0 => 2.0.0 @types/node: ^14.14.10 => 14.14.10 @types/redis: ^2.8.28 => 2.8.28 @types/redis-mock: ^0.17.0 => 0.17.0 @types/sequelize: ^4.28.9 => 4.28.9 @typescript-eslint/eslint-plugin: ^4.9.0 => 4.9.1 @typescript-eslint/parser: ^4.9.0 => 4.9.1 @vue/cli: ^4.5.9 => 4.5.9 @vue/cli-plugin-typescript: ^4.5.8 => 4.5.9 @vue/cli-plugin-unit-jest: ^4.5.11 => 4.5.11 @vue/cli-service: ^4.5.9 => 4.5.9 @vue/eslint-config-typescript: ^7.0.0 => 7.0.0 @vue/test-utils: ^1.1.2 => 1.1.3 @webcomponents/template: ^1.4.3 => 1.4.3 amazon-cognito-identity-js: ^4.5.12 => 4.5.12 auto-sanitize: ^0.1.3 => 0.1.3 aws-amplify: ^3.3.22 => 3.3.22 aws-sdk: ^2.857.0 => 2.857.0 axios: ^0.21.1 => 0.21.1 bluebird: ^3.7.2 => 3.7.2 body-parser: ^1.19.0 => 1.19.0 client-oauth2: ^4.2.5 => 4.2.5 clone: ^2.1.2 => 2.1.2 compression: ^1.7.4 => 1.7.4 connect-redis: ^3.4.2 => 3.4.2 create-output-stream: 0.0.1 => 0.0.1 csrf: ^3.1.0 => 3.1.0 decode-html: ^2.0.0 => 2.0.0 del: ^3.0.0 => 3.0.0 ejs: ^2.7.4 => 2.7.4 email-templates: ^8.0.0 => 8.0.2 eslint: ^6.7.2 => 6.7.2 eslint-config-vuetify: ^0.6.1 => 0.6.1 eslint-plugin-jest: ^24.1.3 => 24.1.5 eslint-plugin-jsdoc: ^15.12.2 => 15.12.2 eslint-plugin-react: ^7.17.0 => 7.17.0 eslint-plugin-require-path-exists: ^1.1.7 => 1.1.9 eslint-plugin-vue: ^7.0.0 => 7.2.0 eslint-plugin-vuetify: ^1.0.0-beta.7 => 1.0.0-beta.7 express: ^4.17.1 => 4.17.1 express-session: ^1.17.0 => 1.17.0 express-winston: ^4.0.5 => 4.1.0 fast-csv: ^2.5.0 => 2.5.0 frameguard: ^3.1.0 => 3.1.0 fs-extra: ^4.0.2 => 4.0.3 glob: ^7.1.6 => 7.1.6 google-libphonenumber: ^3.2.6 => 3.2.6 gulp: ^4.0.2 => 4.0.2 gulp-apidoc: ^0.2.8 => 0.2.8 gulp-autoprefixer: ^6.1.0 => 6.1.0 gulp-babel: ^8.0.0 => 8.0.0 gulp-banner: ^0.1.3 => 0.1.3 gulp-bower: 0.0.14 => 0.0.14 gulp-bower-normalize: ^1.1.1 => 1.1.1 gulp-clean-css: ^4.2.0 => 4.2.0 gulp-concat: ^2.6.1 => 2.6.1 gulp-debug: ^4.0.0 => 4.0.0 gulp-filter: ^5.1.0 => 5.1.0 gulp-image-resize: ^0.13.1 => 0.13.1 gulp-imagemin: ^7.1.0 => 7.1.0 gulp-inject: ^5.0.2 => 5.0.4 gulp-load-plugins: ^2.0.3 => 2.0.6 gulp-notify: ^3.2.0 => 3.2.0 gulp-rename: ^1.3.0 => 1.4.0 gulp-sass: ^4.0.2 => 4.0.2 gulp-sourcemaps: ^2.6.5 => 2.6.5 gulp-typescript: ^6.0.0-alpha.1 => 6.0.0-alpha.1 gulp-uglify: ^3.0.2 => 3.0.2 gulp-util: ^3.0.8 => 3.0.8 html-pdf: ^2.2.0 => 2.2.0 html-to-text: ^5.1.1 => 5.1.1 http-status-codes: ^2.1.4 => 2.1.4 imagemin-pngquant: ^9.0.0 => 9.0.1 inline-css: ^2.5.1 => 2.5.1 jest: ^26.6.3 => 26.6.3 jsdom: 16.4.0 => 16.4.0 jsdom-global: 3.0.2 => 3.0.2 jsforce: ^1.9.3 => 1.9.3 json-stringify-safe: ^5.0.1 => 5.0.1 juice: ^4.3.2 => 4.3.2 jwk-to-pem: ^2.0.4 => 2.0.4 jwt-decode: ^3.1.2 => 3.1.2 main-bower-files: ^2.13.3 => 2.13.3 mixpanel: ^0.10.3 => 0.10.3 moment: ^2.24.0 => 2.24.0 ms: ^2.1.2 => 2.1.2 multer: ^1.4.2 => 1.4.2 mysql: ^2.17.1 => 2.17.1 ngrok: ^3.4.0 => 3.4.0 node-notifier: ^8.0.0 => 8.0.0 node-qpdf: ^1.0.3 => 1.0.3 node-sass: ^4.14.1 => 4.14.1 node-schedule: ^1.3.2 => 1.3.2 nodemailer: ^4.7.0 => 4.7.0 nodemailer-mandrill-transport: ^1.2.0 => 1.2.0 p-queue: ^6.2.1 => 6.2.1 passport: ^0.4.0 => 0.4.0 passport-local: ^1.0.0 => 1.0.0 passport-saml: ^2.0.2 => 2.0.2 pdf-merge: ^1.2.0 => 1.2.0 phaxio-promise: ^0.2.3 => 0.2.3 puppeteer: ^2.0.0 => 2.0.0 redis: ^2.8.0 => 2.8.0 redis-mock: ^0.44.0 => 0.44.0 request: ^2.88.0 => 2.88.0 request-promise: ^4.2.5 => 4.2.5 s3-browser-direct-upload: ^0.1.2 => 0.1.2 samlp: ^4.0.0 => 4.0.0 sass-loader: ^10.1.0 => 10.1.0 semver: ^6.3.0 => 6.3.0 sequelize: ^3.35.1 => 3.35.1 sequelize-cli: ^5.5.1 => 5.5.1 serve-favicon: ^2.5.0 => 2.5.0 serve-static: ^1.14.1 => 1.14.1 sqlite3: ^4.1.0 => 4.1.0 stripe: ^5.10.0 => 5.10.0 taxjar: ^3.2.0 => 3.2.0 toobusy-js: ^0.5.1 => 0.5.1 ts-jest: ^26.4.4 => 26.5.3 ts-node: ^9.1.0 => 9.1.1 twilio: ^3.37.1 => 3.37.1 typescript: ^4.1.2 => 4.1.2 ua-parser-js: ^0.7.20 => 0.7.20 uuid: ^3.3.3 => 3.3.3 vue: ^2.6.12 => 2.6.12 vue-class-component: ^7.2.6 => 7.2.6 vue-jest: ^3.0.7 => 3.0.7 vue-property-decorator: ^9.1.2 => 9.1.2 vue-qrcode-component: ^2.1.1 => 2.1.1 vue-template-compiler: ^2.6.12 => 2.6.12 vuedraggable: ^2.24.3 => 2.24.3 vuetify: ^2.4.2 => 2.4.2 winston: ^3.3.3 => 3.3.3 winston-daily-rotate-file: ^4.5.0 => 4.5.0 ws: ^7.2.0 => 7.2.0 xml-writer: ^1.7.0 => 1.7.0 xregexp: ^3.2.0 => 3.2.0 yargs: ^15.3.1 => 15.4.1 yauzl: ^2.9.1 => 2.10.0 zipcodes: ^6.0.1 => 6.1.0 zxcvbn: ^4.4.2 => 4.4.2 npmGlobalPackages: @aws-amplify/cli: 4.44.2 bower: 1.8.12 gulp-cli: 2.3.0 nodemon: 2.0.7 npm: 6.14.11 sequelize-cli: 6.2.0 typescript: 4.1.5 ```

Describe the bug

The user is blocked from completing the login flow after being given a temporary password and being prompted to enter a new password.

Expected behavior

The user should be allowed to continue the login flow.

Reproduction steps

A user logs in with their initial password (Password A) and logs out. An admin resets the password for the user to a new password (Password B). The user receives an email with Password B. The user enters Password B into the login screen. The user enters their new password (Password C) in the change password screen. And clicks Change. Nothing happens.

At this point, the user has changed their password but is not prompted to continue the login flow. There is an error in the console.

Code Snippet

// Put your code below this line.

Log output

ConsoleLogger.js:107 [DEBUG] 21:21.581 Hub - Dispatching to UI Auth with  {event: "AuthStateChange", message: "resettingpassword", data: CognitoUser}
ConsoleLogger.js:107 [DEBUG] 21:21.594 Hub - Dispatching to UI Auth with  {event: "AuthStateChange", message: "resettingpassword", data: CognitoUser}
ConsoleLogger.js:107 [INFO] 21:21.595 Authenticator - Inside onAuthStateChange Method current authState: signin
ConsoleLogger.js:107 [INFO] 21:21.595 Authenticator - Auth Data was set: CognitoUser {…}
ConsoleLogger.js:97 [INFO] 21:21.596 Authenticator - authState has been updated to resettingpassword
ConsoleLogger.js:107 [DEBUG] 21:21.596 Hub - Dispatching to UI Auth with  {event: "AuthStateChange", message: "resettingpassword", data: CognitoUser}
ConsoleLogger.js:107 [DEBUG] 21:28.561 AuthClass - signIn mfa setup SOFTWARE_TOKEN_MFA
ConsoleLogger.js:107 [DEBUG] 21:28.561 amplify-require-new-password - complete new password CognitoUser {…}
ConsoleLogger.js:107 [DEBUG] 21:28.562 AuthClass - Getting the session from this user: CognitoUser {…}
ConsoleLogger.js:107 [DEBUG] 21:28.562 AuthClass - Failed to get the session from user CognitoUser {…}
Uncaught (in promise) Error: Local storage is missing an ID Token, Please authenticate
    at CognitoUser.getSession (CognitoUser.js:1324)
    at Auth.js:1305
    at new Promise (<anonymous>)
    at AuthClass../node_modules/@aws-amplify/auth/lib-esm/Auth.js.AuthClass.userSession (Auth.js:1303)
    at Auth.js:1030
    at new Promise (<anonymous>)
    at AuthClass../node_modules/@aws-amplify/auth/lib-esm/Auth.js.AuthClass.userAttributes (Auth.js:1029)
    at AuthClass../node_modules/@aws-amplify/auth/lib-esm/Auth.js.AuthClass.verifiedContact (Auth.js:1044)
    at auth-helpers-bd096ca7.js:62
    at step (auth-helpers-bd096ca7.js:32)

aws-exports.js

No response

Manual configuration

No response

Additional configuration

```json { "UserPool": { "SchemaAttributes": [ { "Name": "sub", "StringAttributeConstraints": { "MinLength": "1", "MaxLength": "2048" }, "DeveloperOnlyAttribute": false, "Required": true, "AttributeDataType": "String", "Mutable": false }, { "Name": "name", "StringAttributeConstraints": { "MinLength": "0", "MaxLength": "2048" }, "DeveloperOnlyAttribute": false, "Required": false, "AttributeDataType": "String", "Mutable": true }, { "Name": "given_name", "StringAttributeConstraints": { "MinLength": "0", "MaxLength": "2048" }, "DeveloperOnlyAttribute": false, "Required": false, "AttributeDataType": "String", "Mutable": true }, { "Name": "family_name", "StringAttributeConstraints": { "MinLength": "0", "MaxLength": "2048" }, "DeveloperOnlyAttribute": false, "Required": false, "AttributeDataType": "String", "Mutable": true }, { "Name": "middle_name", "StringAttributeConstraints": { "MinLength": "0", "MaxLength": "2048" }, "DeveloperOnlyAttribute": false, "Required": false, "AttributeDataType": "String", "Mutable": true }, { "Name": "nickname", "StringAttributeConstraints": { "MinLength": "0", "MaxLength": "2048" }, "DeveloperOnlyAttribute": false, "Required": false, "AttributeDataType": "String", "Mutable": true }, { "Name": "preferred_username", "StringAttributeConstraints": { "MinLength": "0", "MaxLength": "2048" }, "DeveloperOnlyAttribute": false, "Required": false, "AttributeDataType": "String", "Mutable": true }, { "Name": "profile", "StringAttributeConstraints": { "MinLength": "0", "MaxLength": "2048" }, "DeveloperOnlyAttribute": false, "Required": false, "AttributeDataType": "String", "Mutable": true }, { "Name": "picture", "StringAttributeConstraints": { "MinLength": "0", "MaxLength": "2048" }, "DeveloperOnlyAttribute": false, "Required": false, "AttributeDataType": "String", "Mutable": true }, { "Name": "website", "StringAttributeConstraints": { "MinLength": "0", "MaxLength": "2048" }, "DeveloperOnlyAttribute": false, "Required": false, "AttributeDataType": "String", "Mutable": true }, { "Name": "email", "StringAttributeConstraints": { "MinLength": "0", "MaxLength": "2048" }, "DeveloperOnlyAttribute": false, "Required": true, "AttributeDataType": "String", "Mutable": true }, { "AttributeDataType": "Boolean", "DeveloperOnlyAttribute": false, "Required": false, "Name": "email_verified", "Mutable": true }, { "Name": "gender", "StringAttributeConstraints": { "MinLength": "0", "MaxLength": "2048" }, "DeveloperOnlyAttribute": false, "Required": false, "AttributeDataType": "String", "Mutable": true }, { "Name": "birthdate", "StringAttributeConstraints": { "MinLength": "10", "MaxLength": "10" }, "DeveloperOnlyAttribute": false, "Required": false, "AttributeDataType": "String", "Mutable": true }, { "Name": "zoneinfo", "StringAttributeConstraints": { "MinLength": "0", "MaxLength": "2048" }, "DeveloperOnlyAttribute": false, "Required": false, "AttributeDataType": "String", "Mutable": true }, { "Name": "locale", "StringAttributeConstraints": { "MinLength": "0", "MaxLength": "2048" }, "DeveloperOnlyAttribute": false, "Required": false, "AttributeDataType": "String", "Mutable": true }, { "Name": "phone_number", "StringAttributeConstraints": { "MinLength": "0", "MaxLength": "2048" }, "DeveloperOnlyAttribute": false, "Required": false, "AttributeDataType": "String", "Mutable": true }, { "AttributeDataType": "Boolean", "DeveloperOnlyAttribute": false, "Required": false, "Name": "phone_number_verified", "Mutable": true }, { "Name": "address", "StringAttributeConstraints": { "MinLength": "0", "MaxLength": "2048" }, "DeveloperOnlyAttribute": false, "Required": false, "AttributeDataType": "String", "Mutable": true }, { "Name": "updated_at", "NumberAttributeConstraints": { "MinValue": "0" }, "DeveloperOnlyAttribute": false, "Required": false, "AttributeDataType": "Number", "Mutable": true }, { "Name": "identities", "StringAttributeConstraints": {}, "DeveloperOnlyAttribute": false, "Required": false, "AttributeDataType": "String", "Mutable": true } ], "EmailVerificationSubject": "Your verification code", "MfaConfiguration": "ON", "AccountRecoverySetting": { "RecoveryMechanisms": [ { "Priority": 1, "Name": "verified_email" } ] }, "SmsAuthenticationMessage": "Your authentication code is {####}. ", "EmailConfiguration": { "EmailSendingAccount": "COGNITO_DEFAULT" }, "AutoVerifiedAttributes": [ "email" ], "UsernameConfiguration": { "CaseSensitive": false }, "LambdaConfig": {}, "LastModifiedDate": 1615313692.652, "AdminCreateUserConfig": { "InviteMessageTemplate": { "EmailMessage": "Your username is {username} and temporary password is {####}. ", "EmailSubject": "Your temporary password", "SMSMessage": "Your username is {username} and temporary password is {####}. " }, "UnusedAccountValidityDays": 7, "AllowAdminCreateUserOnly": false }, "UserPoolAddOns": { "AdvancedSecurityMode": "AUDIT" }, "UsernameAttributes": [ "email" ], "Name": "medicom-jason", "VerificationMessageTemplate": { "EmailMessageByLink": "{##Verify Email##}", "EmailSubjectByLink": "Your email subject", "DefaultEmailOption": "CONFIRM_WITH_LINK", "EmailMessage": "Your verification code is {####}. ", "EmailSubject": "Your verification code", "SmsMessage": "Your verification code is {####}. " }, "Policies": { "PasswordPolicy": { "RequireNumbers": true, "RequireLowercase": true, "RequireSymbols": true, "RequireUppercase": true, "TemporaryPasswordValidityDays": 7, "MinimumLength": 12 } }, "UserPoolTags": {}, "DeviceConfiguration": { "ChallengeRequiredOnNewDevice": false, "DeviceOnlyRememberedOnUserPrompt": false }, "SmsVerificationMessage": "Your verification code is {####}. ", "Domain": "medicom-jason", "EmailVerificationMessage": "Your verification code is {####}. ", "CreationDate": 1614874969.651, "EstimatedNumberOfUsers": 5, "Id": "us-east-1_xxx", "Arn": "arn:aws:cognito-idp:us-east-1:787139455167:userpool/us-east-1_xxx" } } ```

Mobile Device

No response

Mobile Operating System

No response

Mobile Browser

No response

Mobile Browser Version

No response

Screen Shot 2021-03-10 at 9 57 21 AM
amhinson commented 3 years ago

Thanks for all the info! Could you also share a code snippet of your usage? Judging from your dependencies, it looks like you might be using the Amplify UI Components for Vue, but I'd like to confirm first.

jssuttles commented 3 years ago

AmplifyModule.ts

import Amplify, {Auth} from 'aws-amplify';
import '@aws-amplify/ui-vue';

/**
 * Configure Amplify
 *
 * @param region - AWS region
 * @param poolId - id of the pool
 * @param clientId - id of the client within AWS user pool
 */
export default (region:string, poolId:string, clientId:string):void => {
  Amplify.configure({
    aws_project_region: region,
    aws_cognito_identity_pool_id: `${region}:${poolId}`,
    aws_cognito_region: region,
    aws_user_pools_id: `${region}_${poolId}`,
    aws_user_pools_web_client_id: clientId
  });
  Auth.configure({
    storage: sessionStorage
  });
};

AmplifyComponent.vue

<script lang="ts">
import {Component, Prop} from 'vue-property-decorator';
import BaseComponent from './BaseComponent.vue';
import configureAWS from '../helpers/AmplifyModule';

@Component({
  name: 'AmplifyComponent'
})
export default class AmplifyComponent extends BaseComponent {
  @Prop({required:true, type:String})
  readonly awsRegion!:string;

  @Prop({required:true, type:String})
  readonly awsUserPoolId!:string;

  @Prop({required:true, type:String})
  readonly awsClientId!:string;

  /**
   * On created, run this
   */
  configureCognito():void {
    configureAWS(this.awsRegion, this.awsUserPoolId, this.awsClientId);
  }
}
</script>

Login.vue

<template>
  <!-- This v-app does not need the v-application--wrap and classes since it is standalone -->
  <v-app class="vue">
    <v-main class="d-flex align-center">
      <div class="d-flex justify-center">
        <v-card
          class="login-box pt-8 rounded-lg"
          elevation="0"
          outlined
        >
          <v-card-text>
            <v-img
              class="mx-2"
              contain
              max-height="30"
              src="/dist/images/medicom_logo_blue.svg"
            />
            <amplify-authenticator
              username-alias="email"
            >
              <amplify-sign-in
                slot="sign-in"
                hide-sign-up
                username-alias="email"
              />
              <!--          The following does not work. it might after an update -->
              <!--          <amplify-confirm-sign-in-->
              <!--            slot="confirm-sign-in"-->
              <!--            :header-text="labels.SignInHeaderText"-->
              <!--          />-->
              <amplify-forgot-password
                slot="forgot-password"
                :send-button-text="labels.SendResetCodeButton"
                username-alias="email"
              />
              <!--          The following does not work. it might after an update -->
              <!--          <amplify-totp-setup-->
              <!--            slot="totp-setup"-->
              <!--            header-text="Setup Multi-Factor Authentication App"-->
              <!--            issuer="Medicom"-->
              <!--            :user.prop="user"-->
              <!--          />-->
              <div
                v-if="authState === AuthState.SignedIn"
                class="text-center mt-8"
              >
                <v-progress-circular
                  :color="colors.Primary"
                  indeterminate
                  size="70"
                  width="7"
                />
              </div>
            </amplify-authenticator>
            <div
              v-if="authState === AuthState.SignIn && includeFederatedSignIn"
            >
              <v-divider></v-divider>
              <h2>{{labels.SingleSignIn}}</h2>
              <v-btn
                :color="colors.Primary"
                text
                @click="federatedSignIn"
              >
                {{federatedSignInDetails.label}}
              </v-btn>
            </div>
          </v-card-text>
          <v-container
            v-if="this.authState === AuthState.TOTPSetup">
            <h4>Instructions:</h4>
            <div>1. Using your smart phone download/open an Authenticator App.</div>
            <div>2. Scan the qr-code to create a new verification code.</div>
            <div>3. Enter the security code provided on the app.</div>
            <div>4. Click the Verify Security Token button</div>

          </v-container>
        </v-card>
      </div>
    </v-main>
  </v-app>
</template>

<script lang="ts">
import {Component, Prop} from 'vue-property-decorator';
import {AuthState, onAuthUIStateChange} from '@aws-amplify/ui-components';
import {CognitoUser} from 'amazon-cognito-identity-js';

import {labels, urls} from '../helpers/LoginText';
import AmplifyComponent from '../components/AmplifyComponent.vue';
import {VViewNames} from '../helpers/names';
import {Auth} from 'aws-amplify';

type FederatedSignInDetails = {
  cognitoDomain:string,
  providerName:string,
  label:string,
  redirectUri:string,
  scope:string
}

@Component({
  name: VViewNames.Login,
})
export default class Login extends AmplifyComponent {
  @Prop({default: false, type: Boolean})
  readonly includeFederatedSignIn!: boolean;

  @Prop({type: Object})
  readonly federatedSignInDetails!:FederatedSignInDetails|undefined;

  loaded = false;
  authState: AuthState = AuthState.SignIn;
  user:CognitoUser|null=null;

  /**
   * Const AuthState
   */
  get AuthState():typeof AuthState {
    return AuthState;
  }

  /**
   * Const labels
   */
  get labels():typeof labels {
    return labels;
  }

  /**
   * On created event
   */
  created():void {
    this.configureCognito();
    // todo: remove after migration period expired.
    Auth.configure( {
      authenticationFlowType: 'USER_PASSWORD_AUTH'
    });

    onAuthUIStateChange(async (authState:AuthState, authData) => {
      this.authState = authState;
      this.user = authData as CognitoUser;
      if(this.authState !== AuthState.SignedIn || !this.user){
        return;
      }
      const signInUserSession = this.user.getSignInUserSession();
      if (!signInUserSession) {
        // TODO throw error
        return;
      }
      const idToken = signInUserSession.getIdToken().getJwtToken();
      const accessToken = signInUserSession.getAccessToken().getJwtToken();
      location.replace(`/${urls.medicomSignIn}?idToken=${idToken}&accessToken=${accessToken}`);
    });
  }

  /**
   * Trigger federated sign in page
   */
  federatedSignIn():void {
    location.href = `https://${this.federatedSignInDetails.cognitoDomain}.auth.${this.awsRegion}.amazoncognito.com/oauth2/authorize?identity_provider=${this.federatedSignInDetails.providerName}&client_id=${this.awsClientId}&response_type=token&scope=${this.federatedSignInDetails.scope}&redirect_uri=${this.federatedSignInDetails.redirectUri}`;
  }
}
</script>

<style lang="scss">
:root {
  --amplify-primary-color: #002CF0;
  --amplify-primary-tint: #6150F9;
  --amplify-primary-shade: #0020E2;
  --amplify-font-family: Roboto, sans-serif;
  --amplify-text-xxs: 1rem;
  --amplify-text-xs: 1rem;
  --amplify-text-sm: 1rem;
  --amplify-text-md: 1.25rem;
  --amplify-text-lg: 1.50rem;
  --amplify-text-xl: 1.75rem;
  --amplify-text-xxl: 2rem;
}
amplify-authenticator {
  --container-height: 0;
  --box-shadow: 0;
  --min-width:0;
}
.login-box {
  width: 410px;
}
</style>
lorentzca commented 3 years ago

This problem is also reproduced with the @aws-amplify/ui-react 1.2.9. It seems to occur when using TOTP software token MFA. It did not occur when using SMS text message MFA.

Milan-Shah commented 2 years ago

@jssuttles We have recently launched a newer version of Authenticator UI component and a major version for @aws-amplify/ui-react@2.1.0, which has a support for custom styling, zero config, sign up attributes, parity across all web framework, social sign in, password manager support and many more. If you still have any issues, please let us know and we are here to help :)