Amplify-js: CUSTOM_AUTH error when using USER_PASSWORD_AUTH

Created on 26 Nov 2019  路  12Comments  路  Source: aws-amplify/amplify-js

I've setup amplify on my Vue app to use some custom config. I've set all my user pool settings etc and set authenticationFlowTypeto USER_PASSWORD_AUTH. However, when i attempt to sign in using a username(email) with the password set to an empty string I get an error saying Custom auth lambda trigger is not configured for the user pool.

In my main.ts file I have:

import Amplify from '@aws-amplify/core';
import awsconfig from './aws-exports';

Amplify.configure(awsconfig);
Vue.prototype.$Amplify = Amplify;

and from my component I call this.$Amplify.Auth.signIn(this.email, this.password)

When both the username and password is set though, I get a username/password is incorrecty type of error. Is there any reason for this?

I'm using aws-amplify version 2.1.0. I had the same problem on 1.2.4 too.

Auth pending-close-response-required

Most helpful comment

@rayhaanq I believe when there is no password the library is assuming you want to do a CUSTOM_AUTH authentication flow, which requires a Lambda trigger. I suspect if you checked the network request when there is no password, you'll see that the flow type is CUSTOM_AUTH.

I am investigating the other issue.

All 12 comments

@rayhaanq I believe when there is no password the library is assuming you want to do a CUSTOM_AUTH authentication flow, which requires a Lambda trigger. I suspect if you checked the network request when there is no password, you'll see that the flow type is CUSTOM_AUTH.

I am investigating the other issue.

@rayhaanq It looks like your Amplify configuration is not specifying that you want to use USER_PASSWORD_AUTH instead of USER_SRP_AUTH. This is a non-default option you need to manually configure, as SRP is a better practice. Please be aware that the USER_PASSWORD_AUTH will send passwords over the network.

Here is how you can configure it, if you want to:

Auth.configure({
  ...awsconfig,
  authenticationFlowType: 'USER_PASSWORD_AUTH'
});

You will also need to go to the User Pool in the Cognito console and then, in the App Clients section, select 'Enable username password based authentication (ALLOW_USER_PASSWORD_AUTH)'.

This issue has been automatically closed because of inactivity. Please open a new issue if are still encountering problems.

How can I refactor this error message. I am using the aws-amplify-react-native package imports.

Custom auth lambda trigger is not configured for the user pool. to Please enter the password

How can I refactor this error message. I am using the aws-amplify-react-native package imports.

Custom auth lambda trigger is not configured for the user pool. to Please enter the password

You can update the error message by using the Amplify Message Map.

const mapErrorMessages = message => {
  if(message === "Custom auth lambda trigger is not configured for the user pool."){
    return "Please enter your password"
  }
  return message;
};

Pass your setup to the Authenticator component using the errorMessage prop.

More on the Authenticator Component

Here's the code for mapping custom error messages to the Authenticator Component:

const AppWithAuth = () => {
  const mapErrorMessages = message => {
    if(message === "Custom auth lambda trigger is not configured for the user pool."){
      return "Please enter your password"
    }
    return message;
  };

  return (
    <Authenticator
      errorMessage={mapErrorMessages}
    >
      <App />
    </Authenticator>
  );
};

export default AppWithAuth;

Thanks, but i found this already.

@philateatclub I have a question here. If I modify the error message Attempt limit exeeded, please try again later to Invalid phone number. Both will change the messages in the Forgot password and Confirmation code screen.

Can I able to find the screen names in aws-amplify-react-native. I am using the same screens not the customized screens.

Also

Did you know how to reload the screens. (i.e) error message is retained in the screen after revisits the screen

Still same error!!! After refractoring also..plzz help

@nihp did you ever figure out the answers to either of your questions? I am wondering the same

Used Hub.listen to find the events. Otherwise If you have custom screens inside the you need to navigate using this this.props.onStateChange('forgotPassword',{})

@nihp What was your solution for the errorMessages reloading?

I have set a state in the screen for validations.

While navigating from a screen to another screen, I have set the validation as empty.
Look this https://github.com/aws-amplify/amplify-js/issues/2104#event-3577102889

(i.e) If I am in login screen. I gave a wrong password it shows Username/password is incorrect. So I navigate to Forgot password. While click on the forgot password I have set the error state as empty with all other fields. So it will clear while navigating alone.

This is a solution which I have used. Because from this aws-amplify library there is no solution still now.

<TouchableOpacity onpress={this.gotoForgotPassword}/>

```
gotoForgotPassword = () => {
const { password, email, error, loggedIn, dialCode } = this.state;

  let validateUser = {
   isValidUserName: true,
   isFormValidUser: true,
   isValidPassword: true,
   validUserMessage: []
  }
  this.setState({email: '', dialCode:'+1', password:'', validateUser:validateUser })
  this.props.onStateChange('forgotPassword',{});
}

```

Workaround!
Use the "AmplifyConfirmSignUp" and force the user to type the password again, and process should work as expected.
Looks like when you submit the form without password, it get's identified as "CUSTOM"

import {
  AmplifyAuthenticator,
  AmplifySignIn,
  AmplifySignUp,
  AmplifyConfirmSignIn,
  AmplifyConfirmSignUp
} from '@aws-amplify/ui-react';

...

<AmplifyConfirmSignUp
                slot="confirm-sign-up"
                formFields={[
                  {
                    type: 'email',
                    label: 'Email',
                    placeholder: 'Type your email',
                    required: true,
                  },{
                    type: 'code',
                    label: 'Code',
                    placeholder: 'Type the confirmation code',
                    required: true,
                  },
                  {
                    type: 'password',
                    label: 'Password',
                    placeholder: 'Type your password',
                    required: true,
                  },
]}></AmplifyConfirmSignUp>
Was this page helpful?
0 / 5 - 0 ratings