Maptio / maptio

http://www.maptio.com
Other
23 stars 4 forks source link

An edge case showing confusing information about inviting existing Google users. #839

Open rgoj opened 8 months ago

rgoj commented 8 months ago

Problem

This is a complex edge case, something that so far appears to have happened only once here: https://app.intercom.com/a/inbox/q3x5lnhp/inbox/shared/all/conversation/106323200014043

We are overloading user.isActivationPending with multiple meanings, which I've not realised until now. On the one hand, this is used to check whether someone has completed their signup process, i.e. whether they have completed their profile. On the other hand, this is used to indicate whether someone has accepted an invitation or not (and thus whether or not to display the "invite" button).

There is an odd edge case where this overload is problematic. In the ticket linked to above, a user had created a Maptio account 4 months ago, but, crucially, and unusually, not completed their signup process (hence user.isActivationPending was still equal to true!). Then, someone else created an organisation, added the user and then attempted to invite the user. The system correctly recognised that there was an existing user with that email already and the person inviting the user accepted the proposed solution to add the existing user. At this stage everything is normally OK (apart from the fact that we should be and aren't sending an email to the user when they're added to a new organisation!), the user appears as Active and has access to the organisation. In this case, the user appeared as "Not yet invited" (isInvitationSent is false because, of course, the Google user never had an invitation sent to them!) and it was still possible to press the "Invite" button. Pressing it led to an error on the server because (I'm assuming, haven't dug into this bit in depth) you can't send a password change email to a non-password-social-login-based user! (And we send password change emails rather than invitations due to that ugly Auth0 workaround, sigh, another piece of this puzzle!) The person pressing the invite button then saw a "Something went wrong. Please try again later or contact us if the problem persists."

Instructions for reproducing

See detailed description above

Expected behavior

An existing social login user should simply be added to the new team when their account is found. They should also be sent an email letting them know they can access a new team with their existing Maptio account.

Additional context

If this problem ever occurs again, what I did to fix it up in this instance was simply to set isActivationPending to false for that user. They can then log in and access the new team they were added to (well, they could already most likely - tested locally) and they show up, correctly (if a bit confusingly!) as "Active" in the list of the people in the organisation.