Azkar Moulana
Azkar Moulana

Reputation: 894

How to define the user object for AWS Amplify Cognito Auth.SignUp() method?

I'm creating a serverless authentication backend with AWS Amplify Cognito and I'm using Angular as my front-end framework. Instead of using the built in aws UI components for signin/signup interfaces, I crated my own user interfaces. When I try to submit the user object to Auth.SignUp() I found no documentation related to that in AWS Amplify documentation. If you have implemented this in your own please share it here.

Upvotes: 0

Views: 445

Answers (1)

Engam
Engam

Reputation: 1061

This is how I have implemented it (in Angular)

Auth service:

import Auth from '@aws-amplify/auth';
...
customSignupFunction(usrname, psw, phone) {
    const username = usrname;
    const password = psw;
    const phone_number = phone;

    return Auth.signUp({
      username,
      password,
      attributes: {
        phone_number,
        //more attributes
      }
    }).then(res => {
      //do something
    }).catch(err => console.error(err))
  }

Upvotes: 1

Related Questions