fabscale / ember-cognito-identity

Interact with AWS Cognito in your Ember app.
MIT License
0 stars 0 forks source link

Add "Sign Up" method #721

Open hoIIer opened 2 years ago

hoIIer commented 2 years ago

Hello, I'm investigating this as a replacement for ember-cognito due to a blocking bug brought about by reliance on @aws-amplify.

The only thing stopping me is that this library is missing a signup method. Is there a reason for that? Can we add it?

If we can add that I think this is a great replacement for ember-cognito.

At first I was going to suggest making this compatible with ember-simple-auth, but I'm not sure it's even necessary and I like the idea of thin packages.

Thanks!

hoIIer commented 2 years ago

cognito.userPool.signUp() exists but when I tried using it I got a serialization error from aws... will look into it further.

hoIIer commented 2 years ago

Was able to get it working via below:

import AmazonCognitoIdentity from 'amazon-cognito-identity-js';

        ...

        const attributes = [
          new AmazonCognitoIdentity.CognitoUserAttribute({
            Name: 'email',
            Value: email,
          }),
          new AmazonCognitoIdentity.CognitoUserAttribute({
            Name: 'custom:foo',
            Value: 'bar',
          }),
        ];

        await this.cognito.userPool.signUp(
          email,
          password,
          attributes,
        );
mydea commented 2 years ago

Hi, no specific reason for not adding this except that I didn't need it so far ;) I'd be happy to accept a PR adding this functionality. Other than this, it should also be totally fine to use the user pool like you did in your example!

hoIIer commented 2 years ago

Hey, ok yeah the signup needs better handling for promises like below: https://github.com/aws-amplify/amplify-js/blob/main/packages/auth/src/Auth.ts#L362-L388

Will see if I can take a crack at it later this week perhaps

mydea commented 2 years ago

Yeah, you'll need to wrap it like the other methods - I guess it should be realtively straightforward to follow the same schema as for all the other stuff, but let me know if you need guidance somewhere!