Wp-calypso: Signup: login redirect broken if 'user' step not first in flow

Created on 23 Jun 2020  Ā·  5Comments  Ā·  Source: Automattic/wp-calypso

I've noticed that if the user signup step is not at the first place in a signup flow, redirecting from the login screen (after clicking "Already have a WP account?") back to the signup flow resets the progress and user ends up in a loop so that you can't create a new site by logging in to an existing account.

For example, go to wordpress.com/start/developer. Fill in the site and go to the user step. There, click on "Already have a WP account?". Log in. You'll be redirected back to wp.com/start/developer. However, you'll land on the new site step again and have to repeat your desired site address. Only then you successfully finish the flow.

Screen Shot 2020-06-23 at 14 54 47

I noticed this as we are working on the P2 signup flow and have the user step as the last one instead of the first one which triggers this behavior.

Signup [Type] Bug

All 5 comments

cc @Automattic/ganon for help here too 😊

Recent findings:

  • The problem is that when you are redirected to log into your wpcom account and then redirected back to the signup flow, Redux state is cleared and it doesn't remember the signup progress (state/signup/progress).
  • It works for all the flows which have user step as the first one as there's no progress made — you first log in, then are redirected back to the signup flow. The user step is removed from the flow and you can continue the flow as normal.
  • However, if the user step is not in the first place of a signup flow, the signup progress gets cleared/reset on redirecting from the wpcom login screen.
  • Even though the state/signup subtree is persisted (with it state/signup/progress) it's somehow cleared after redirecting from the login screen back to the signup flow.

We should find out why and how the state/signup subtree is cleared and if possible, prevent it so we can continue with the signup flow from the last finished step.

We should find out why and how the state/signup subtree is cleared and if possible, prevent it so we can continue with the signup flow from the last finished step.

Maybe this will help explain why we cleared the store after login: https://github.com/Automattic/wp-calypso/pull/38330

Back in the day, we had to clear the signup store so that we could ensure users could return to the onboarding flow in a clean state.

https://github.com/Automattic/wp-calypso/blob/4d27b9a/client/signup/main.jsx#L362

Maybe you could toy around with clearing based on the flow?

Also, @andrewserong implemented an A/B experiment that pushed the user step to the last step in the flow, while preserving user data: https://github.com/Automattic/wp-calypso/pull/34770

That might yield some clues as well as how to approach it for the p2 flow.

This is great info @ramonjd, thanks for the pointers! Gonna check it now.

So, this recent PR https://github.com/Automattic/wp-calypso/pull/44106 helped to transfer the signup redux state from the logged out session to the logged in session.

However, I found out it’s ā€œfarā€ from being done and fixed. ā€œfarā€ in quotes because it might not be too much code but in order to completely fix it, I have to fully understand the core signup logic which is kinda huge.

In https://github.com/Automattic/wp-calypso/pull/34770, what they did was to dispatch a ā€œresumeā€ action after logging in which would mark the last step as ā€˜in-progress’ so user would be redirected to it. The downside is that the user has to repeat the last step. The upside that it helps the signup flow process stuff in normal way.

It wouldn’t help us much because our flow basically has only one step (the p2-site one). So what I’m trying to do is to automagically submit and process the p2-site step after logging in.

I think I might have some solution which I’ll try but it’s not super nice.

tl;dr signup flow was not made for these kinds of things and it needs a bit of rework or perhaps hacks around (which I’m trying) which might be ugly and not pass review.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

serabi picture serabi  Ā·  66Comments

supernovia picture supernovia  Ā·  49Comments

correliebre picture correliebre  Ā·  83Comments

marianearchimbaud picture marianearchimbaud  Ā·  52Comments

AMcGrady picture AMcGrady  Ā·  62Comments