aws-amplify / amplify-js

A declarative JavaScript library for application development using cloud services.
https://docs.amplify.aws/lib/q/platform/js
Apache License 2.0
9.44k stars 2.13k forks source link

Hub auth events for new user signing up with social oauth providers #11087

Open yunchanpaik opened 1 year ago

yunchanpaik commented 1 year ago

Is this related to a new or existing framework?

React

Is this related to a new or existing API?

Authentication

Is this related to another service?

Cognito

Describe the feature you'd like to request

I would like to display an onboarding flow (mostly introductory and guides) for the new user signing up to my service.

In order to accomplish this, my app is listening to the Auth events signUp which is called for new users. However, if the user signs up using the Google Oauth provider, only the signIn and cognitoHostedUI events are called which makes it impossible to distinguish between the new user and the returning user.

Describe the solution you'd like

oAuthSignUp event should be called for the new user signing up with oauth providers

Describe alternatives you've considered

I considered handling this in the backend by calling the api to check if the user has already seen the onboarding flow or not.

This method requires an extra (and unnecessary) server call after the user signs up and causes additional delay.

Additional context

No response

Is this something that you'd be interested in working on?

tannerabread commented 1 year ago

Hi @yunchanpaik this seems like a valid feature request.

Are you only looking for the additional sign-up event? Asking because you mentioned you wanted an onboarding flow but I assume you were going to handle the rest within your app.

yunchanpaik commented 1 year ago

Hi @tannerabread, yes I just need an additional sign-up event for tracking new users signing up with the social oauth providers.

I am basically trying to provide an unboxing experience for the users similar to this.

How soon can I expect the change? Thanks!

tannerabread commented 1 year ago

I will bring this up with the rest of the team and try to get this prioritized but I can't promise any specific timeline. We do accept contributions/PRs though and try to prioritize merging those as well. If you want to go that route please follow these guidelines to contributing!

Thank you for the clarity on what you are looking for

yunchanpaik commented 1 year ago

Great! Thanks for sharing the guidelines to contribute. I will look into it as well.

kevoj7 commented 1 year ago

Any updates on this? This seems like a no brainer?

How was this not thought of?

enisze commented 10 months ago

I would be interested in this as well, why is there no event for sign up? This blocks me from updating from the old @aws-amplify package :/

israx commented 10 months ago

hello @enisze . Could you elaborate the use case to use the sign up event ?

Auth in amplify-js v6 is dispatching events for APIs that can't be resolved on the same call, with the exception of signIn.

kevoj7 commented 10 months ago

Issue is, unless you have customState added to the function call, you won't know if a user selected sign in / sign up.

The nature of the issue is probably because a user will mostly like click signin (sso sign in) by mistake and it will trigger the wrong workflow if they need to sign up. Also, having a distinct function for signup/signin is more straight forward - from a workflow perspective it can be more tailored to the UX.

Also the amplify authenticator ui does NOT allow you to pass custom oauth events, so that becomes pretty useless. I've had to reinvent the wheel with that UI card and add my custom ouath events with custom state so that when a user hits sign in (signinwithredirect), it will also send the custom state "sign in, if they hit sign up custom state "sign up"(signinwithredirect).

I've had to work around these limitations, not sure how other are doing it.

enisze commented 10 months ago

@kevoj7 could you share your code for the custom signUp?

@israx main issue is regarding tracking what the user did exactly. For analytics.

Meags27 commented 10 months ago

I need this too, after a user signs up with hosted UI, need to redirect them to setup multi-factor authentication. And I also need to update their email preferences if they subscribed to marketing/news emails too.

israx commented 10 months ago

@Meags27 . Amplify is not able to know when a user has signed-up using the Hosted UI.

when Hosted UI is used to authenticate or sign-in, it will redirect to the provided redirectSignIn and will attach either a code or token as query params. Then, the library will complete the authentication process. So this is how the library is able to know when the user has authenticated or is signed-in.

However this is not the case for sign-up. The library is not able to know the exact moment that a user has finished the registration process because the Hosted UI is not communicating to the App.

There might be a potential workaround though. You would need to configure the POST Confirmation lambda and find a way to notify the client that the user has finished the registration process. Probably by having a subscription with GraphQL

israx commented 10 months ago

@enisze if you are not using the hosted-ui for sign-up, then there is no need to depend on a hub event. You can mainly depend on the response of the sign-up API and continue with the registration process. However if you are mainly depending on the hosted-ui, then it is not possible for Amplify to know when the user has signed-up.

aprilmintacpineda commented 6 months ago

Seems that the Authenticator component isn't really emitting an event for sign ups. However, the signIn event will be emitted afterwards because the user is automatically signed in after signing up.

cscetbon commented 5 months ago

I will bring this up with the rest of the team and try to get this prioritized but I can't promise any specific timeline.

It's been a year, any update on this ? Also I don't think it's a feature request, it's a bug that we have a hub that doesn't catch SignedUp auth events ...